* Disable 1-field simplification by default
This builds on top of #1315 to minimize disruption by disabling the
breaking change by default and instead requiring the user to opt in
by setting a new `collapseSingletonRecords` option to `True`.
The additional tests added to verify this also caught a bug in the
`Interpret` instance for functions, which this change also fixes.
* Change to three-valued option
... based on feedback from @sjakobi
This change the option to a three-valued option:
* `Bare` - 1-field constructor does not include a nested record
* `Wrapped` - 1-field constructor always includes a nested record
* `Smart` - Named fields that don't begin with `_` include a nested record
The default is `Wrapped` (for backwards compatibility), but users will
probably want to eventually switch to `Smart`
* Don't depend on `fieldModifier` for determining if a field is anonymous
... as suggested by @sjakobi
* Refactor `Dhall.Eval`
This updates the style of `Dhall.Eval` to match the stylistic
and naming conventions of the rest of the `dhall` package.
* Import `Data.Set` fully qualified
... as suggested by @sjakobi
* Re-enable warnings
... as wished by @sjakobi
* Remove `{eval,conv,quote}E` synonyms
... as suggested by @sjakobi
* INLINE `qVar`
... literally
... as suggested by @sjakobi
* Remove unnecessary `MIN_VERSION_base(4,8,0)`
... as caught by @sjakobi
We still need `CPP` elsewhere within the same file, though
* Fix style of `vProjectByFields` function
... as caught by @sjakobi
* 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`
Fixes a type mismatch error message which mentions JSON.
Fixes an "arithmetic overflow" exception which occurs when attempting to
parse a negative number as a `Natural`.
* 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!
* Use `tasty-expected-failure`
... to exercise tests that we currently skip
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1245
* Fix bounds syntax for `tasty-expected-failure`
... as caught by @sjakobi
Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>
* Fix GHC 8.6 build failure
`tasty-expected-failure` needs to be bumped to include revision 1, which
supports GHC 8.6
* Fix build failure for older `tasty-hunit` versions
`tasty-hunit-0.9.2` and older have the wrong type for `assertFailure`
* Fix `stack` build for LTS 6
... and sort the list of `extra-deps`