dhall-haskell/dhall
Gabriel Gonzalez 47383de623 Update Dhall.Tutorial module (#1439)
* Update `Dhall.Tutorial` module

This overhauls the `Dhall.Tutorial` module to reflect recent changes to
the language (and also to link to external documentation when possible).

* Fix doctests

* Rephrase import syntax caveat

... as suggested by @sjakobi

* Explain `<<<`

... as suggested by @sjakobi@

* Rephrase things

... as suggested by @sjakobi

* `s/The annotated/This/`

... as caught by @sjakobi

* Add commas to description of link to built-ins reference

... as caught by @sjakobi

Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>

* Remove paragraph describing role of Prelude

* Update dhall/src/Dhall/Tutorial.hs

... as suggested by @sjakobi

Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>
2019-10-20 00:38:07 +00:00
..
benchmark Fix dhall format to preserve let comments (#1273) 2019-09-04 23:41:44 -05:00
dhall Migrate dhall-{bash,json,text} into this repository (#661) 2018-10-28 17:32:51 -07:00
dhall-lang@f296d7d641 Add new record completion operator (#1375) 2019-10-11 08:26:51 -07:00
doctest Update Dhall.Tutorial module (#1439) 2019-10-20 00:38:07 +00:00
examples Migrate dhall-{bash,json,text} into this repository (#661) 2018-10-28 17:32:51 -07:00
ghc-src/Dhall 100% haddock coverage (#1416) 2019-10-13 22:22:39 -07:00
ghcjs-src/Dhall Fix CI to properly reject incomplete haddocks (#1418) 2019-10-16 19:49:44 -07:00
src Update Dhall.Tutorial module (#1439) 2019-10-20 00:38:07 +00:00
tests Rename Interpret to FromDhall, Inject to ToDhall (#1437) 2019-10-19 03:24:49 +00:00
CHANGELOG.md Use a more conventional spelling for "etags", mostly just use "tags" (#1432) 2019-10-19 01:59:29 +00:00
default.nix Install mostly static executables on OS X when using Nix (#830) 2019-03-04 19:43:31 -08:00
dhall.cabal Add --file option for dhall hash (#1445) 2019-10-19 22:38:44 +00:00
LICENSE Migrate dhall-{bash,json,text} into this repository (#661) 2018-10-28 17:32:51 -07:00
README.md Rename Interpret to FromDhall, Inject to ToDhall (#1437) 2019-10-19 03:24:49 +00:00
Setup.hs Migrate dhall-{bash,json,text} into this repository (#661) 2018-10-28 17:32:51 -07:00
shell.nix Migrate dhall-{bash,json,text} into this repository (#661) 2018-10-28 17:32:51 -07:00

dhall

For installation or development instructions, see:

Full documentation here:

Introduction

Dhall is a programmable configuration language that is not Turing-complete

You can think of Dhall as: JSON + functions + types + imports

Motivation

"Why not configure my program using JSON or YAML?"

JSON or YAML are suitable for small configuration files, but larger configuration files with complex schemas require programming language features to reduce repetition. Otherwise, the repetitive configuration files become error-prone and difficult to maintain/migrate.

This post explains in more detail the motivation behind programmable configuration files:

"Why not configure my program using Haskell code?"

You probably don't want to rebuild your program every time you make a configuration change. Recompilation is slow and requires the GHC toolchain to be installed anywhere you want to make configuration changes.

Example

Given this Haskell program saved to example.hs:

-- example.hs

{-# LANGUAGE DeriveGeneric     #-}
{-# LANGUAGE OverloadedStrings #-}

import Dhall

data Example = Example { foo :: Integer, bar :: Vector Double }
    deriving (Generic, Show)

instance FromDhall Example

main :: IO ()
main = do
    x <- input auto "./config"
    print (x :: Example)

... which reads in this configuration file:

$ cat ./config
{ foo = 1
, bar = ./bar
}

... which in turn references this other file:

$ cat ./bar
[3.0, 4.0, 5.0]

... you can interpret the Haskell program like this:

$ nix-shell ../nix/test-dhall.nix
[nix-shell]$ runghc example.hs
Example {foo = 1, bar = [3.0,4.0,5.0]}

You can also interpret Dhall programs directly using the installed command-line compiler:

$ dhall
List/head Double ./bar
<Ctrl-D>
Optional Double

Some 3.0

... and you can reference remote expressions or functions by their URL, too:

$ dhall
let null = https://raw.githubusercontent.com/dhall-lang/Prelude/35deff0d41f2bf86c42089c6ca16665537f54d75/List/null
in  null Double ./bar
<Ctrl-D>
Bool

False

Now go read the Dhall tutorial to learn more.

Standard-compatibility table

Haskell package version Supported standard version
1.20.* 5.0.0
1.19.* 4.0.0
1.18.* 3.0.0
1.17.* 2.0.0
1.16.* 1.0.0