2018-12-29 18:48:21 +01:00
|
|
|
# `dhall-bash`
|
2018-10-29 01:32:51 +01:00
|
|
|
|
2018-12-10 21:28:19 +01:00
|
|
|
For installation or development instructions, see:
|
|
|
|
|
|
|
|
* [`dhall-haskell` - `README`](https://github.com/dhall-lang/dhall-haskell/blob/master/README.md)
|
|
|
|
|
2018-12-13 15:44:33 +01:00
|
|
|
Full documentation here:
|
|
|
|
|
|
|
|
* [`dhall-bash` instructions](https://hackage.haskell.org/package/dhall-bash/docs/Dhall-Bash.html)
|
|
|
|
|
2018-12-10 21:28:19 +01:00
|
|
|
## Introduction
|
|
|
|
|
2018-10-29 01:32:51 +01:00
|
|
|
This `dhall-bash` package provides a Dhall to Bash compiler so that you can
|
|
|
|
easily marshall Dhall values into your Bash scripts
|
|
|
|
|
|
|
|
This does not compile all available Dhall language constructs into Bash and
|
|
|
|
only supports extracting primitive values, lists, optional values and records
|
|
|
|
from normalized expressions.
|
|
|
|
|
2018-12-03 17:30:30 +01:00
|
|
|
## Example
|
2018-10-29 01:32:51 +01:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$ dhall-to-bash <<< '1'
|
|
|
|
1
|
|
|
|
$ dhall-to-bash <<< '"ABC" ++ "DEF"'
|
|
|
|
ABCDEF
|
|
|
|
$ dhall-to-bash --declare FOO <<< '"ABC" ++ "DEF"'
|
|
|
|
declare -r FOO=ABCDEF
|
|
|
|
$ eval $(dhall-to-bash --declare FOO <<< '"ABC" ++ "DEF"')
|
|
|
|
$ echo "${FOO}"
|
|
|
|
ABCDEF
|
|
|
|
$ dhall-to-bash --declare BAR
|
2018-12-03 17:30:30 +01:00
|
|
|
let replicate = https://prelude.dhall-lang.org/List/replicate
|
2018-12-01 16:52:00 +01:00
|
|
|
in replicate 10 Natural 1
|
2018-10-29 01:32:51 +01:00
|
|
|
<Ctrl-D>
|
|
|
|
declare -r -a BAR=(1 1 1 1 1 1 1 1 1 1)
|
|
|
|
$ dhall-to-bash --declare BAZ <<< '{ qux = 1, xyzzy = True }'
|
|
|
|
declare -r -A BAZ=([qux]=1 [xyzzy]=true)
|
|
|
|
```
|