This replaces all uses of `NeatInterpolation` with either multi-line
strings or `unlines`. This allows Dhall to be compiled without using
Template Haskell, which in turn enables cross-compilation
This reverts commit 8c340c12dd.
The reason for reverting this change is that using the same
operator name for appending `Text` and `List`s complicates
compilation to other languages. For example, the `dhall-to-nix`
compiler currently translates `TextAppend` to `+`, but if you
consolidate `List` and `Text` append under a single `Append`
constructor then the translation to Nix is harder: you'd have to
do type inference as part of the translation process to know which
Nix operator to translate to.
Added `normalizeWith` function to complement `typeWith`.
Dhall is so very attractive base for simple DSLs that I felt it
needed to be pushed over the edge.
Naturally, using `normalizeWith` loses all the nice features of Dhall.
If your context isn't total or strongly normalizing then embedding it
to Dhall will not improve things.
Added a function that allows doing `input` from a closed
Dhall `Expr` instead of text. This is hugely useful when
working with Dhall in AST level (for example, using custom
types / normalization). For example, suppose that you have
built a custom primitive that requires a record as an argument.
With `rawInput` you can just extract the record into a Haskell
data type and process it without need to work with maps and other
bits of AST.
For context of this commit, see #79 (and also #26).
This rearranges each detailed error message so that the summary of relevant
Dhall expressions goes at the end of the message. This allows users to easily
obtain this information without having to browse the entire error message.
Users can now supply additional headers for URL imports using the new `using`
keyword, like this:
```haskell
http://example.com using ./headers
```
... where `./headers` must be a value of type:
```haskell
{ header : Text, value : Text }
```
The argument to `using` must be an import (such as a file, URL, or env import)
and cannot be an inline Dhall expression. There are two reasons why:
* The header expression is resolved, type-checked, and normalized in a separate
phase preceding the import of the corresponding URL so it does not have access
to bound variables in scop
* This restriction greatly simplifies the implementation
Also, headers are automatically forwarded to relative imports, so if you import a
URL like this:
```haskell
http://example.com using ./headers
```
... and that serves a file like:
```haskell
./foo
```
... then Dhall will import `http://example.com/foo` using the same `./headers`.
Before this change, if you saved the following files:
```bash
$ echo "~/bar" > /tmp/foo
$ echo "./baz" > ~/bar
$ echo "1" > ~/baz
```
... then you would get the following error:
```bash
$ dhall <<< '/tmp/foo'
↳ ./foo
↳ ~/.bar
↳ ./baz
Error: Missing file
```
This is because path canonicalization had a bug where relative directories like
`./baz` do not get correctly resolved relative to home-anchored directories like
`~/.bar`. The compiler instead mistakenly tried to locate a non-home-anchored
`./baz` file, which does not exist.
After this fix, the above code resolves correctly tries to resolve `~/baz` as
the last file in the import chain and succeeds with:
```bash
$ dhall <<< '/tmp/foo'
Integer
1
```
You can now interpolate any expression of type `Text` into a string literal,
like this:
```haskell
let renderRating
= λ(rating : { name : Text, rating : Natural })
→ let score = Integer/show (Natural/toInteger rating.rating)
in ''
# My thoughts about ${rating.name} (${score} out of 5)
''
in renderRating { name = "Dhall", rating = +6 }
```
The previous tests for `build . fold` fusion for `Optional` values would
succeed even without fusion. This change updates the tests to only
succeed if fusion is occurring.
This change updates the test to test Dhall source code so that we're
exercising the system from end to end. This also makes it easier to
author tests since expressions can be written as Dhall source code
instead of an abstract syntax tree.