-
-
Dhall is…
-
A programming language
-
Purely functional
-
Strongly typed
-
Not Turing complete
-
… YAML?
-
Data
{
user = "singpolyma",
groups = ["web", "xmpp"]
}
-
Code
let map = https://prelude.dhall-lang.org/v9.0.0/List/map
let UserConfig = { user : Text, groups : List Text }
let users = ["singpolyma", "otherguy"]
in
map
Text
UserConfig
(\(user: Text) -> { user = user, groups = ["web", "xmpp"] })
users
-
Normalize
$ dhall < t.dhall
[ { groups = [ "web", "xmpp" ], user = "singpolyma" }
, { groups = [ "web", "xmpp" ], user = "otherguy" }
]
-
YAML
$ dhall-to-yaml < t.dhall
- groups:
- web
- xmpp
user: singpolyma
- groups:
- web
- xmpp
user: otherguy
-
Dhall is structured templating
-
dhall-rails I18n
{
en = {
ducks =
\(translation_name: < ducks >) ->
\(args: { count: Natural }) ->
"${Natural/show args.count} ducks"
}
}
-
Dhall safety features
-
Limited access to the world
-
Integrity protection
https://example.com/code.dhall sha256:9946ffab…
-
Same origin policy
-
Total (not Turing complete)
-
You can still be dumb on purpose
let iterate
: (Natural → Natural) → Natural → Natural
= λ(f : Natural → Natural)
→ λ(n : Natural)
→ Natural/fold (n + 1) Natural f 1
let increment : Natural → Natural = λ(n : Natural) → n + 1
let ackermann
: Natural → Natural → Natural
= λ(m : Natural) →
Natural/fold m (Natural → Natural) iterate increment
in ackermann
-
Some nice features
-
Multiline string
\(someArg: Text) ->
''
This is a template contaning ${someArg}.
We can use ${someArg} more than once.
''
-
Optionals
Some 1 : Optional Natural
None Natural : Optional Natural
-
Enums
let colours = < Red | Green | Blue >
in
merge {
Red = "#f00",
Green = "#0f0",
Blue = "#00f"
} colours.Red
-
Questions?