-
-
Notifications
You must be signed in to change notification settings - Fork 182
Frequently Asked Questions (FAQ)
This page has moved to docs.dhall-lang.org - Frequently Asked Questions (FAQ)
This copy of the page will no longer be kept up-to-date
All top-level imports are relative to the current working directory. For example, if you
have a file located at ./foo/bar.dhall that tries to import ./foo/baz.dhall via a
relative import:
$ cat ./foo/bar.dhall./baz.dhall$ cat ./foo/baz.dhall1... that relative import will not work correctly if you feed that file to a Dhall interpreter via standard input:
$ dhall < ./foo/bar.dhall
↳ ./baz.dhall
Error: Missing file ./baz.dhallThis is because the interpreter does not know that the string fed in via standard
input originally came from ./foo/bar.dhall. Therefore, the interpreter cannot
process the relative import correctly.
However, the relative import does work correctly if you pass the program using
the --file flag, like this:
$ dhall --file ./foo/bar.dhall1The Dhall configuration language provides language support for completing a record with default-valued fields using the :: operator.
For example, in Python you can write:
def greet(greeting="Hello", name="John"):
print("{0}, {1}!".format(greeting, name))
greet()
greet(greeting="Hola")
greet(name="Jane")
greet(greeting="Hola",name="Jane")... which produces this result:
$ python greet.py
Hello, John!
Hola, John!
Hello, Jane!
Hola, Jane!The Dhall equivalent of the above code would be:
let greet =
\(args : { greeting : Text, name : Text })
-> "${args.greeting}, ${args.name}!"
let Greeting =
{ Type = { greeting : Text, name : Text }
, default = { greeting = "Hello", name = "John" }
}
in ''
${greet Greeting::{=}}
${greet Greeting::{ greeting = "Hola" }}
${greet Greeting::{ name = "Jane" }}
${greet Greeting::{ greeting = "Hola", name = "Jane" }}
''... which produces the same result:
$ dhall text --file ./greet.dhall
Hello, John!
Hola, John!
Hello, Jane!
Hola, Jane!dhall lint:
-
Removes unused
letbindings -
Consolidates nested
letbindings to use a multiple-letbindingSee: Add support for
letexpressions with multipleletbindings -
Fixes
letbindings containing equivalences (≡) that were probably intended as assertions.
You have to nest updates, like this:
let example = { coordinate = { x = 5, y = 3 }, element = "Hg" }
in example // {
coordinate = example.coordinate // {
x = example.coordinate.x + 1
}
} Dhall cannot infer a polymorphic type for an empty list because Dhall represents polymorphic values as functions of types, like this:
\(a : Type) -> [] : List aIf the compiler treated an empty list literal as syntactic short-hand for the above polymorphic function then you'd get the unexpected behavior where a list literal is a function if the list has 0 elements but not a function otherwise.
No, but you can translate recursive code to non-recursive code by following this guide:
This work is licensed under a Creative Commons Attribution 4.0 International License.
- Home
- Discussion
- Tutorials
- How-to guides
- References