Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign up[Question] Reading a file to Text #139
Comments
This comment has been minimized.
This comment has been minimized.
|
Like this: |
This comment has been minimized.
This comment has been minimized.
|
Incredible! Maybe it should be added to |
This comment has been minimized.
This comment has been minimized.
|
Oops! For some reason I thought that the tutorial did mention this feature, but I now see that it's not there. I'll update the documentation |
This comment has been minimized.
This comment has been minimized.
|
One last question: can I do substitution/templating on such
Normally, if this Text was inlined, I’d just use |
This comment has been minimized.
This comment has been minimized.
|
The best you can do in Dhall is to go back to -- hello.dhall
λ(name : Text) → ''
Hello, ${name}!
''... and then in { hello = ./hello.dhall "Gabriel439"
}... or if you want to pass named arguments to -- hello.dhall
λ(args : { name : Text }) → ''
Hello, ${args.name}!
''... and then reference that like this: { hello = ./hello.dhall { name = "Gabriel439" }
}However, you can't retroactively modify a value of type In fact, the string templating syntax in Dhall is syntactic sugar for λ(name : Text) → ''
Hello, ${name}!
''... is the same as this Dhall expression: λ(name : Text) → "Hello, " ++ name ++ "!" |
This comment has been minimized.
This comment has been minimized.
|
Thank you for this detailed answer. Lack of retroactive modification makes a lot of sense (do $x well from the beginning), but still I had this slight hope. Thank you! |
michalrus
closed this
Sep 25, 2017
This comment has been minimized.
This comment has been minimized.
|
You're welcome! Also, I will reopen this issue to remind myself to fix the documentation to mention support for |
michalrus commentedSep 25, 2017
Hey!
How can I read a file into a
: Textvalue? Likelet text = builtins.readFile ./some-file.txtin Nix.I could wrap it in😛
''s and then do a standard import, but it’s not exactly convenient.Thanks!