Giter Site home page Giter Site logo

`Text` vs. `as Text` about dhall-lang HOT 13 CLOSED

dhall-lang avatar dhall-lang commented on September 27, 2024
`Text` vs. `as Text`

from dhall-lang.

Comments (13)

Gabriella439 avatar Gabriella439 commented on September 27, 2024

This limitation is intentional. Imported Dhall expressions (such as ./template) have to be closed (i.e. no free variables like value in your example) so that they can be type-checked in isolation.

from dhall-lang.

angerman avatar angerman commented on September 27, 2024

Is there a way around it? E.g. to inject some textual value verbatim prior to the typechecker?

Iā€˜d rather not have a \(...) -> '' first and '' last line in say a HTML file.

from dhall-lang.

Gabriella439 avatar Gabriella439 commented on September 27, 2024

Yes, but only if you're willing to use the Haskell API to build your own tool. The Haskell API provides a typeWith function that you can use to type-check expressions using your own custom context. Similarly, there is a normalizeWith that you can use to inject custom values

from dhall-lang.

angerman avatar angerman commented on September 27, 2024

Could dhall-to-text gain a primitive for that, hypothetically speaking?

from dhall-lang.

Gabriella439 avatar Gabriella439 commented on September 27, 2024

Yeah, I'd be fine with providing a utility function that bundles typeWith+normalizeWith+{adding single quotes before parsing}

from dhall-lang.

asivitz avatar asivitz commented on September 27, 2024

I would love this. I was thinking about making a Dhall compiler for Hakyll, and would probably end up implementing this myself if it weren't in the Dhall lib.

from dhall-lang.

f-f avatar f-f commented on September 27, 2024

Should we move this issue to dhall-haskell?
As far as I understand it is about adding a flag (--wrap-text?) to dhall-to-text

from dhall-lang.

Gabriella439 avatar Gabriella439 commented on September 27, 2024

@f-f: Yes, my understanding is that this is a dhall-haskell-related issue, although I think the request here is for a new function in the Haskell API for ease of templating rather than a new command-line option.

from dhall-lang.

Nadrieril avatar Nadrieril commented on September 27, 2024

Having the ability to import templates from files sounds cool though.
I imagine the following: if file contains "A ${string} with ${interpolations}", then (./file as Template) { string = "blah", interpolations = "blih" } would normalize to the string "A blah with blih". That would allow big templates to be put separately, while still requiring imported expressions to be closed.

from dhall-lang.

Gabriella439 avatar Gabriella439 commented on September 27, 2024

@Nadrieril: See the discussion on the linked pull request:

dhall-lang/dhall-haskell#205

... and also the discussion on this related issue:

dhall-lang/dhall-haskell#676

from dhall-lang.

Nadrieril avatar Nadrieril commented on September 27, 2024

Oh. Too bad, I liked this idea, but you make convincing points

from dhall-lang.

ocharles avatar ocharles commented on September 27, 2024

dhall-lang/dhall-haskell#205 says

I'll go ahead and close this since it's unlikely to be added to the language standard

Should this issue also be closed?

from dhall-lang.

Gabriella439 avatar Gabriella439 commented on September 27, 2024

Yeah, I will close this issue, too

from dhall-lang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.