* Simplify `Inject`/`Interpret` for 1-field records
Fixes https://github.com/dhall-lang/dhall-haskell/issues/346
Now a Haskell type like:
```haskell
data Example = Foo Bool | Bar Text
```
... corresponds to this Dhall type:
```dhall
{ Foo : Bool | Bar : Text }
```
* Fix documentation
* Add additional test cases
... as suggested by @sjakobi
* Test all permutations of:
* 0, 1, or 2 fields
* Fields of type `()` or `Double`
* Named or anonymous fields
To type-check and evaluate inputs in the context of previous
inputs, the repl constructs a let-expression that includes
the previous input and variable assignments as bindings.
Previously these bindings would also be annotated with
inferred types. For example a session like
⊢ Kind
⊢ "foo"
would be represented as
let it : Sort = Kind
in "foo"
However `Sort` does not typecheck as an annotation of a let-binding,
resulting in the confusing message
Error: ❰Sort❱ has no type, kind, or sort
Constructing the let-bindings without the type annotations fixes the
problem.
Fixes#1193.
Since some inferred types are in non-normal form, `dhall type`
would previously return types that weren't strictly
standard-conforming. This change prevents further confusion.
Closes#1300.
* Add `--censor` switch for disabling source code display
Related to #1294
This currently only affects parse errors, but can later be extended
to type errors, too
* Fix type blindiness
... as requested by @sjakobi
* Replace `Bool` with `Censor`
* Replace `Maybe FilePath` with `Input`
* Simplify recursive `Interpret` instance
Related to https://github.com/dhall-lang/dhall-haskell/issues/1297
The motivation behind this change is to:
* Remove the dependency on `free` and `distributive`
* Simplify the API and the implementation
* Fix `stack-lts-6` build
* Remove now-unused test files
... as caught by @sjakobi
When enabled, we handle protected imports as if the semantic cache was
empty:
* Protected imports are resolved again, downloaded or read from
the filesystem as necessary.
* Protected imports are β-normalized, not αβ-normalized.
* Protected imports are checked against their SHA256 hashes,
failing to resolve if they don't match.
Context:
https://github.com/dhall-lang/dhall-haskell/pull/1275#issuecomment-528847192
* Add a haddock to explain the various `Binding` fields.
* Add combinators to make dealing with `Binding` less awkward.
With all of the source information flying around, manually
deconstructing and reconstructing `Binding`s is a pain. These
combinators cover some very common cases.
* Use `bindingExprs` to simplify `subExpressions`.
* Use bindingExprs and chunkExprs to simplify another traversal.
Full coverage of all Expr constructors is now checked by the
type-checker. This revealed that that the IntegerToDouble, TextShow,
Some and None constructors were missing.
Also:
* Increase frequency for Lam, Pi and App
* Fix a few inconsistencies in normalization
* Remove some dead code in D.T.QuickCheck
Closes#1256.
* Change `dhall type` to resolve imports
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1277
The original motivation was that `dhall type` would represent a
type-inference-only phase. However, in practice that wasn't very useful
so `dhall type` now performs import resolution followed by type inference.
* Fix loading relative to root directory
... as caught by @sjakobi
Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>
Closes#1185.
This mostly reverts "Add support for multi-`let` (#675)" /
8a5bfaa3b9.
Also:
* Add fields for Src
This is useful for to make 'Note's less noisy during debugging:
first srcText expr
* Small fixes to `dhall diff`
Related to https://github.com/dhall-lang/dhall-haskell/issues/1255
* Simplify function type diffs by omitting the bound variable name when possible
* Non-zero exit code when `dhall diff` is non-empty
Note that this is a breaking change to the `Dhall.Diff` API by changing the
exposed utilities to all expose the more general `Diff` type instead of a
`Doc`. This means that we also no longer need separate exports for
`diff` and `diffExpression`.
* Fix build failure for tests
* Fix golden test result
* Rename `diffExpression` to `diff`
... as suggested by @sjakobi
* Add test coverage for diffing function types
* Fix `Inject` instance for lists
Fixes#1254
This also adds tests for conversions back and forth between Dhall and
Haskell values
* Add `Inject` instances for `Scientific` and `String`
... so that we don't need to comment them out!
This is essentially the exact same problem and fix as #1213
Normally I would add a test, except that our test suite for diffs doesn't
yet support escape codes. However, the basic problem was the following
output:
```
$ dhall diff '"1"' '"2"'
- "…"
+ "…"
```
... which now displays (with color highlighting) this output:
```
$ dhall diff '"1"' '"2"'
"12" -- Imagine that the 1 is red and the 2 is green
```
* Improve HTTP errors
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1251
This improves HTTP error messages by:
* Expanding the set of recognized status codes
* Adding up to 7 lines of the response body
For example:
```
Error: Remote file missing
URL:
↳ https://httpbin.org/statu
Message:
1│ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2│ <title>404 Not Found</title>
3│ <h1>Not Found</h1>
4│ <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
```
* Always include HTTP status code in output
... as suggested by @sjakobi
* Use "not found" wording for 404 message
This is closer to the official wording for the error message
* Compress error message formatting
There's no need to put the URL and status code on separate lines since
they are compact
* [dhall format] Prefer unquoted URLs
This updates `dhall format` to prefer unquoted URLs.
I included the test cases described in #1109, but along the way I
discovered a standard bug so I have opened dhall-lang/dhall-lang#704 to
fix it. This change depends on that upstream fix.
Fixes#1109.
* pull in latest dhall-lang
* skip unimplemented tests
The new tests were introduced in dhall-lang/dhall-lang#698.
Also:
* Document shortcommings of Expr's Eq and Ord instances.
Haddock for GHC-7.10.3 can't handle haddocks on vanilla derived
instances, so we use StandaloneDeriving.
* Add explanation for skipped AssertNaN test
* Make equivalences of terms of different types fail during typechecking
This fixes the `EquivalenceNotSameType` test from
https://github.com/dhall-lang/dhall-lang/pull/698.
* s/assertion/equivalence
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1211
The original implementation of diffing two lists in #450 attempted to add a
special case in the logic for when the list had no common elements.
However, this led to a bug where the two lists would display different
if they were both empty.
lists would never render.
This change fixes that by removing the special case.
The new output for the linked example is:
```
Use "dhall --explain" for detailed errors
Error: Assertion failed
[ …
, - 1
, …
, + 55
]
16│ assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ]
17│
(stdin):16:16
```
Previously, normalizing `Natural/subtract 0` would result in this
error:
⊢ Natural/subtract 0
Error: Compiler bug
An ill-typed expression was encountered during normalization.
Explanation: This error message means that there is a bug in the Dhall compiler.
You didn't do anything wrong, but if you would like to see this problem fixed
then you should report the bug at:
https://github.com/dhall-lang/dhall-haskell/issues
CallStack (from HasCallStack):
error, called at src/Dhall/Eval.hs:865:38 in dhall-1.25.0-FCOZ7uxqivz8dkVwuN7aED:Dhall.Eval
This updates the dhall-lang submodule to include a new testcase added
in https://github.com/dhall-lang/dhall-lang/pull/692.
* Remove Dhall.X and replace with Data.Void
This commit removes the Dhall.X module and the Dhall.X.X type,
preferring the use of Data.Void.Void. As I'm sure a lot of people are
actually using X, I've added a type-alias type X = Void. However,
pattern matching on X would be a breaking change.
Fixes#1120.
* Restore unsafeCoerce
* Fix regression
* Unused
* Reorganise exports
* Fix dhall-nix
* Another fix
* Fix Dhall.LSP.Backend.Typing
* Fix dhall-bash