|
1 |
| -# `dhall 1.18.0` |
| 1 | +# `dhall-haskell` |
2 | 2 |
|
3 |
| -Dhall is a programmable configuration language that is not Turing-complete |
| 3 | +This repository is a shared repository for all of the `dhall-*` Haskell |
| 4 | +packages, including: |
4 | 5 |
|
5 |
| -You can think of Dhall as: JSON + functions + types + imports |
| 6 | +* [`dhall`](./dhall) |
| 7 | +* [`dhall-bash`](./dhall-bash) |
| 8 | +* [`dhall-json`](./dhall-json) |
| 9 | +* [`dhall-text`](./dhall-text) |
6 | 10 |
|
7 |
| -You will probably want to read the language-agnostic README here: |
| 11 | +Navigate to each package's directory for their respective `README`s |
8 | 12 |
|
9 |
| -* [`dhall-lang` `README`](https://github.com/dhall-lang/dhall-lang/blob/master/README.md) |
| 13 | +# Quick start |
10 | 14 |
|
11 |
| -This repository (and this `README`) focuses on the Haskell implementation of |
12 |
| -Dhall |
| 15 | +You can build all of the packages by running: |
13 | 16 |
|
14 |
| -## Motivation |
15 |
| - |
16 |
| -*"Why not configure my program using JSON or YAML?"* |
17 |
| - |
18 |
| -JSON or YAML are suitable for small configuration files, but larger |
19 |
| -configuration files with complex schemas require programming language features |
20 |
| -to reduce repetition. Otherwise, the repetitive configuration files become |
21 |
| -error-prone and difficult to maintain/migrate. |
22 |
| - |
23 |
| -This post explains in more detail the motivation behind programmable |
24 |
| -configuration files: |
25 |
| - |
26 |
| -* [Programmable configuration files](https://github.com/dhall-lang/dhall-lang/wiki/Programmable-configuration-files) |
27 |
| - |
28 |
| -*"Why not configure my program using Haskell code?"* |
29 |
| - |
30 |
| -You probably don't want to rebuild your program every time you make a |
31 |
| -configuration change. Recompilation is slow and requires the GHC toolchain |
32 |
| -to be installed anywhere you want to make configuration changes. |
33 |
| - |
34 |
| -## Quick start |
35 |
| - |
36 |
| -Given this Haskell program saved to `example.hs`: |
37 |
| - |
38 |
| -```haskell |
39 |
| --- example.hs |
40 |
| - |
41 |
| -{-# LANGUAGE DeriveGeneric #-} |
42 |
| -{-# LANGUAGE OverloadedStrings #-} |
43 |
| - |
44 |
| -import Dhall |
45 |
| - |
46 |
| -data Example = Example { foo :: Integer, bar :: Vector Double } |
47 |
| - deriving (Generic, Show) |
48 |
| - |
49 |
| -instance Interpret Example |
50 |
| - |
51 |
| -main :: IO () |
52 |
| -main = do |
53 |
| - x <- input auto "./config" |
54 |
| - print (x :: Example) |
55 |
| -``` |
56 |
| - |
57 |
| -... which reads in this configuration file: |
58 |
| - |
59 |
| -```bash |
60 |
| -$ cat ./config |
61 |
| -{ foo = 1 |
62 |
| -, bar = ./bar |
63 |
| -} |
64 |
| -``` |
65 |
| - |
66 |
| -... which in turn references this other file: |
67 |
| - |
68 |
| -``` |
69 |
| -$ cat ./bar |
70 |
| -[3.0, 4.0, 5.0] |
71 | 17 | ```
|
72 |
| - |
73 |
| -... you can interpret the Haskell program like this: |
74 |
| - |
75 |
| -```bash |
76 |
| -$ nix-shell nix/test-dhall.nix |
77 |
| -[nix-shell]$ runghc example.hs |
78 |
| -Example {foo = 1, bar = [3.0,4.0,5.0]} |
79 |
| -``` |
80 |
| - |
81 |
| -You can also interpret Dhall programs directly using the installed command-line |
82 |
| -compiler: |
83 |
| - |
84 |
| -```bash |
85 |
| -$ dhall |
86 |
| -List/head Double ./bar |
87 |
| -<Ctrl-D> |
88 |
| -Optional Double |
89 |
| - |
90 |
| -Some 3.0 |
91 |
| -``` |
92 |
| - |
93 |
| -... and you can reference remote expressions or functions by their URL, too: |
94 |
| - |
95 |
| -```bash |
96 |
| -$ dhall |
97 |
| -let null = https://github.com/raw/dhall-lang/Prelude/35deff0d41f2bf86c42089c6ca16665537f54d75/List/null |
98 |
| -in null Double ./bar |
99 |
| -<Ctrl-D> |
100 |
| -Bool |
101 |
| - |
102 |
| -False |
103 |
| -``` |
104 |
| - |
105 |
| -Now go read the |
106 |
| -[Dhall tutorial](https://hackage.haskell.org/package/dhall/docs/Dhall-Tutorial.html) |
107 |
| -to learn more |
108 |
| - |
109 |
| -## Building this project |
110 |
| - |
111 |
| -Nix + Cabal is the recommended workflow for project development since continuous |
112 |
| -integration uses Nix to build and test the project. Other development tools and |
113 |
| -workflows are also supported on a best-effort basis. |
114 |
| - |
115 |
| -You can build the project using only Nix by running this command from the root |
116 |
| -of the repository: |
117 |
| - |
118 |
| -```bash |
119 | 18 | $ nix-build
|
120 | 19 | ```
|
121 | 20 |
|
122 |
| -More commonly, you will want to incrementally build the project using `cabal`. |
123 |
| -You can either do so inside of a `nix-shell`: |
124 |
| - |
125 |
| -```bash |
126 |
| -$ nix-shell |
127 |
| -[nix-shell]$ cabal configure |
128 |
| -[nix-shell]$ cabal build |
129 |
| -[nix-shell]$ cabal test |
130 |
| -``` |
131 |
| - |
132 |
| -... or you can add `nix: True` to your `~/.cabal/config` file and then you can |
133 |
| -run the same `cabal` commands without an explicit `nix-shell`: |
134 |
| - |
135 |
| -```bash |
136 |
| -$ cabal configure |
137 |
| -$ cabal build |
138 |
| -$ cabal test |
139 |
| -``` |
| 21 | +... or you can run `nix-build` within each package's respective directory to |
| 22 | +build just that one package. |
140 | 23 |
|
141 | 24 | ## Development status
|
142 | 25 |
|
|
0 commit comments