dhall-lang.org
Open in
urlscan Pro
2600:3c01::f03c:91ff:fe40:4ef3
Public Scan
Submitted URL: http://dhall-lang.org/
Effective URL: https://dhall-lang.org/
Submission: On April 30 via api from GB — Scanned from GB
Effective URL: https://dhall-lang.org/
Submission: On April 30 via api from GB — Scanned from GB
Form analysis
0 forms found in the DOMText Content
* Get started * Discussion Programmable configuration files Core language features Safety guarantees Dhall in production Design choices * Tutorial Getting started: Generate JSON or YAML Language tour Learn Dhall in Y minutes dhall-nethack * How-to guides How to integrate Dhall Cheatsheet Frequently Asked Questions (FAQ) How to translate recursive code to Dhall How to add a new built-in function How to type-check and normalize incomplete code How to validate a configuration file * References Grammar Semantics Built-in types, functions, and operators Prelude * Languages Bash Clojure Go Haskell Nix Ruby Rust * File formats YAML JSON XML * Packages Ansible Argo CD CloudFormation Concourse Docker GitLab kops Kubernetes Nomad Prometheus * * * * * * * * THE DHALL CONFIGURATION LANGUAGE Maintainable configuration files Dhall is a programmable configuration language that you can think of as: JSON + functions + types + imports * Hello, world! * Definitions * Functions * Types * Imports xxxxxxxxxx 12 1 {- This is an example Dhall configuration file 2 3 Can you spot the mistake? 4 5 Fix the typo, then move onto the "Definitions" 6 example 7 -} 8 9 { home = "/home/bill" 10 , privateKey = "/home/bill/.ssh/id_ed25519" 11 , publicKey = "/home/blil/.ssh/id_ed25519.pub" 12 } * Type * Normalized * Hash * JSON * YAML xxxxxxxxxx 1 home: /home/bill 2 privateKey: /home/bill/.ssh/id_ed25519 3 publicKey: /home/blil/.ssh/id_ed25519.pub 4 DON'T REPEAT YOURSELF Struggling with configuration drift? Create a single source of truth you can reference everywhere. -------------------------------------------------------------------------------- > "Configuration drift occurs when a standardized group of IT resources, be they > virtual servers, standard router configurations in VNF deployments, or any > other deployment group that is built from a standard template, diverge in > configuration over time. … The Infrastructure as Code methodology from DevOps > is designed to combat Configuration Drift and other infrastructure management > problems." > > Kemp Technologies on Configuration Drift > > -------------------------------------------------------------------------------- Create a single authoritative configuration file: xxxxxxxxxx 39 1 -- ./company.dhall 2 3 let Prelude = 4 https://prelude.dhall-lang.org/v19.0.0/package.dhall sha256:eb693342eb769f782174157eba9b5924cf8ac6793897fc36a31ccbd6f56dafe2 5 6 let companyName = "Example Dot Com" 7 8 let User = { name : Text, account : Text, age : Natural } 9 10 let users 11 : List User 12 = [ { name = "John Doe", account = "john", age = 23 } 13 , { name = "Jane Smith", account = "jane", age = 29 } 14 , { name = "William Allen", account = "bill", age = 41 } 15 ] 16 17 let toEmail = \(user : User) -> "${user.account}@example.com" 18 19 let Bio = { name : Text, age : Natural } 20 21 let toBio = \(user : User) -> user.(Bio) 22 23 let companySize = Prelude.List.length User users 24 25 let greetingPage = … that you can read directly into several languages or convert to other file formats (including YAML or JSON). xxxxxxxxxx 19 1 $ dhall-to-yaml <<< '(./company.dhall).bios' 2 - age: 23 3 name: John Doe 4 - age: 29 5 name: Jane Smith 6 - age: 41 7 name: William Allen 8 9 $ dhall-to-bash --declare EMAILS <<< '(./company.dhall).emails' 10 declare -r -a EMAILS=(john@example.com jane@example.com bill@example.com) 11 12 $ dhall text <<< '(./company.dhall).greetingPage' 13 <html> 14 <title>Welcome to Example Dot Com!</title> 15 <body> 16 <p>Welcome to our humble company of 3 people!</p> 17 </body> 18 </html> 19 Supported integrations FEARLESSLY REFACTOR Need to clean up a big mess? Move fast without breaking things by leaning on Dhall's tooling. -------------------------------------------------------------------------------- Refactoring something mission-critical? Use Dhall's support for semantic hashes to guarantee that many types of refactors are behavior-preserving -------------------------------------------------------------------------------- What if you intend to make a change? Use a semantic diff to verify that you changed what you expected to: xxxxxxxxxx $ dhall diff \ 'https://prelude.dhall-lang.org/v18.0.0/package.dhall' \ 'https://prelude.dhall-lang.org/v19.0.0/package.dhall' { + Operator = … , `Optional` = { + concatMap = … , … } , … } -------------------------------------------------------------------------------- Did you inherit a messy configuration? Use the type system and integrated editor support to navigate more effectively. VSCode plugin SAFETY FIRST Sick of Turing-complete configuration languages? Dhall is a total programming language that forbids arbitrary side effects. -------------------------------------------------------------------------------- We take language security seriously so that your Dhall programs never fail, hang, crash, leak secrets, or compromise your system. The language aims to support safely importing and evaluating untrusted Dhall code, even code authored by malicious users. We treat the inability to do so as a specification bug. Safety guarantees USE PROGRAMMING LANGUAGE FEATURES Hold your configuration files to the same standard of quality as the rest of your code. -------------------------------------------------------------------------------- xxxxxxxxxx 52 1 -- Import packages 2 let JSON = 3 https://prelude.dhall-lang.org/v19.0.0/JSON/package.dhall sha256:79dfc281a05bc7b78f927e0da0c274ee5709b1c55c9e5f59499cb28e9d6f3ec0 4 5 -- Use precise types like enums instead of strings 6 let Zone = < us-east-1 | us-west-1 > 7 8 let InstanceType = < `m5.large` | `m5.xlarge` > 9 10 let Instance = { type : InstanceType, zone : Zone } 11 12 -- JSON rendering can optionally be implemented entirely within the language 13 let Zone/toJSON = 14 \(zone : Zone) 15 -> merge 16 { us-east-1 = JSON.string "us-east-1" 17 , us-west-1 = JSON.string "us-west-1" 18 } 19 zone 20 21 let InstanceType/toJSON = 22 \(type : InstanceType) 23 -> merge 24 { `m5.large` = JSON.string "m5.large" 25 , `m5.xlarge` = JSON.string "m5.xlarge" > "Configuration bugs, not code bugs, are the most common cause I've seen of > really bad outages. … As with error handling, I'm often told that it's obvious > that config changes are scary, but it's not so obvious that most companies > test and stage config changes like they do code changes." > > Dan Luu in Reading postmortems Get started -------------------------------------------------------------------------------- This work is licensed under a Creative Commons Attribution 4.0 International License.