Dhall
The YAML killer :)
Dhall is a programmable configuration language
You:
Dont:
Want:
Me:
To:
Write:
- YAML
1. YAML is only easy to read/write if you use a small subset of it. YAML specs are huge (>20k lines). 9 ways to write multi line string.
2. YAML is not portable (https://matrix.yaml.io/valid.html)
3. Surprising behaviour
- Don Corleone: Do you have faith?
- Clemenza: Yes
- Don Corleone: Do I have your loyalty?
----
python: 3.5.3
postgres: 9.3
----
Effenaar: Eindhoven
013: Tilburg
[{'Don Corleone': 'Do you have faith?'},
{'Clemenza': True},
{'Don Corleone': 'Do I have your loyalty?'}]
----
{'python': '3.5.3',
'postgres': 9.3}
----
{11: 'Tilburg',
'Effenaar': 'Eindhoven'}
4. Quickly you roll out your own version of YAML with its own rules.
Why DHALL?
1. Total - Evaluation always terminates and never hangs or infinitely loops
2. Safe - Evaluation never crashes or throws exceptions
3. Distributed - Expressions can reference other expressions by URL or path
4. Strongly normalizing - All expressions (even functions) have a normal form
5. Statically typed - Configurations can be validated ahead-of-time
6. Strongly typed - No coercions, casts or subtyping
7. Built-in data types - Includes lists, anonymous records and anonymous unions
What is DHALL?
Think of it as:
JSON
+
functions
+
types
+
imports
{ home = "/home/rok"
, privateKey = "/home/rok/.ssh/id_rsa"
, publicKey = "/home/rok/.ssh/id_rsa.pub"
}
let mkUser = \(user : Text) ->
{ home = "/home/${user}"
, privateKey = "/home/${user}/.ssh/id_rsa"
, publicKey = "/home/${user}/.ssh/id_rsa.pub"
}
in mkUser "rok"
Let User : Type =
{ home : Text
, privateKey : Text
, publicKey : Text
}
let mkUser : Text -> User = \(user : Text) ->
{ home = "/home/${user}"
, privateKey = "/home/${user}/.ssh/id_rsa"
, publicKey = "/home/${user}/.ssh/id_rsa.pub"
}
in mkUser "rok" : User
...
let generate = https://prelude.dhall-lang.org/List/generate
in generate 10 User (\index : Natural -> mkUser "build${Natural/show index}")
DEMO
Integrations
Bidnings
Output formats
Libraries
Editor integration:
Thank you
DhallDhall
By Rok Garbas
DhallDhall
- 1,359