Fixes#714
This adds a `--json` flag that `dhall decode` and `dhall encode` can use to
read/write the equivalent JSON representation of the CBOR. This comes in
handy for the parsing compliance tests which use this CBOR-as-JSON as the
standard representation of the abstract syntax tree.
Now that `constructors x` is the same as `x` we can have `dhall lint`
safely strip all uses of `constructors` in preparation for removing the
keyword entirely.
Fixes#509
The `Dhall.Import.HTTP` module had logic for pretty-printing HTTP error
message, but this logic wasn't being used anywhere! This change fixes
that and also polishes the error messages a little bit.
* Add dotgen as a dependency
Signed-off-by: Basile Henry <bjm.henry@gmail.com>
* Build up dot graph while resolving imports
Signed-off-by: Basile Henry <bjm.henry@gmail.com>
* Add --dot option to resolve in CLI
Signed-off-by: Basile Henry <bjm.henry@gmail.com>
* Handle diamond dependencies in dot graph
* Refactor dot graph generation
This fixes an apparently very old bug in import caching caught by @basile-henry
Before this change the import resolution algorithm was:
1. Retrieving the cache
2. Transitively resolving all imports
3. Setting the new cache to be current import insert into the cache retrieved in
step 1
The bug is that all of the transitive imports resolved in step 2 added
entries of their own to the cache and those new cache entries were being
clobbered by step 3.
The fix is simple: don't use the cache retrieved in step 1 to compute
the updated cache in step 3. Rather, use `modify` instead of `put` to
create the new cache so that we preserve newly-added cache entries.
`dhall lint` was incorrectly deleting `let` bindings that are being used
due to not checking other `let` bindings within the same multi-`let`
expression for free variable occurrences.
This change fixes that and adds the first regression test for `dhall
lint`
Fixes#692
The standard permits a user to access a constructor from a type stored inside
a record, but the Haskell implementation had a mistake which prevented this.
Specifically, the Haskell implementation was not normalizing the union type
as the standard specified before attempting to access the constructor, leading
to an unexpected type error.
This begins updates the filesystem layout for the tests to match
the new layout from the standard test suite (See:
https://github.com/dhall-lang/dhall-lang/pull/265)
This is still missing a part of the standard requirement, which is checking
parsing and import test results against an expected output (instead of
just checking that they succeed). I plan to add that in a subsequent
pull request. This is mainly to unblock other features that require using
the new standard layout.
CI was running tests, but they weren't blocking merge because they weren't a
dependency of the `dhall` attribute (which is what gates the GitHub status).
This fixes that by adding `coverage.dhall` as a dependency (which does include
tests). The other builds were not running tests since that is what happens
`coverage` defaults to `false`.
Fixes https://github.com/dhall-lang/dhall-lang/issues/267
According to the standard, Unicode characters up to `0x10FFFF` do not
require escaping. See:
33cab24f8e/standard/dhall.abnf (L192)
... so we can preserve them when pretty-printing Dhall expressions.
Note that the current code still does not comply with the standard for Unicode
characters beyond `0x10FFFF`, but I'll defer fixing that to a subsequent
change.
This ensures that all of the `dhall-*` libraries build against
GHC 8.6.1, but still generates tarballs using GHC 8.4.3 and
uses GHC 8.4.3 for development
The issue was that the parser was attempting to parse // first, which
will succeed on the prefix of //\\, then the parser will get an error
because it expects a sub expression but the input is \\.
The motivation for this change is:
* To catch build failures in downstream packages whenever we make a breaking
change to the `dhall` API
* To reduce the amount of work I need in order to cut a release for all of
these packages
* To better share Nix/CI-related logic between the projects
Note that I have not yet migrated `dhall-nix` in. I'm waiting for
https://github.com/dhall-lang/dhall-nix/issues/17 to be fixed since
`dhall-nix` is incompatible with later versions of `megaparsec` due to
`hnix`.
This contains subExpressions, a traversal that visits all immediate
sub-Expr's of an Expr. This is a fairly fundamental traversal, which is
extremely useful when combined with idioms from Control.Lens.Plated,
allowed for very easy rewriting of ASTs.
Fixes#655
The standard grammar specifies that `Some` must be followed by
non-empty whitespace, so that an identifier like `SomeCons` is not
parsed as `Some Cons`.
Fixes https://github.com/dhall-lang/dhall-haskell/issues/645
Fixes https://github.com/dhall-lang/dhall-lang/issues/216
This updates the `README` with the following changes:
* Points to the language-agnostic `README` in the `dhall-lang` repository
* Retains only Haskell-specific sections of interest
* Removes the embedded LICENSE now that GitHub auto-recognizes the project
license (#644)
* Changes the Quick Start instructions to use Nix
* Adds instructions for project development using Nix
The latter two points entailed refactors to the Nix logic to simplify the
user experience:
* `default.nix` was moved to `shared.nix` and replaced with a new `default.nix`
that works out-of-the-box with `nix-build`
* There is a new `nix/test-dhall.nix` which users can use to create a
`nix-shell` with Dhall as a dependency
Here’s an example:
./polyfunctor
```dhall
λ(j : Kind)
→ λ(k : Kind)
→ λ(c : j → j → Type)
→ λ(d : k → k → Type)
→ λ(f : j → k)
→ { map : ∀(a : j) → ∀(b : j) → c a b → d (f a) (f b) }
```
then
```dhall
./polyfunctor
Type
Type
(λ(a : Type) → λ(b : Type) → a → b)
(λ(a : Type) → λ(b : Type) → a → b)
Optional
```
normalizes to
```dhall
{ map : ∀(a : Type) → ∀(b : Type) → (a → b) → Optional a → Optional b }
```
and
```dhall
./polyfunctor
(Type → Type)
(Type → Type)
(λ(a : Type → Type) → λ(b : Type → Type) → ∀(i : Type) → a i → b i)
(λ(a : Type → Type) → λ(b : Type → Type) → ∀(i : Type) → a i → b i)
```
normalizes to
```dhall
λ(f : (Type → Type) → Type → Type)
→ { map :
∀(a : Type → Type)
→ ∀(b : Type → Type)
→ (∀(i : Type) → a i → b i)
→ ∀(i : Type)
→ f a i
→ f b i
}
```
See the discussion in https://github.com/dhall-lang/dhall-lang/issues/242
and the corresponding change the standard in
https://github.com/dhall-lang/dhall-lang/pull/243 for more context.
At some point we want to extend support for older versions of the standard
as far back as possible, but in order to do this correctly we need to
provide a way to systematically thread the standard version to everything
that we standardize, including:
* type-checking
* β-normalization
* α-normalization
* import resolution
* binary encoding/decoding
... and that entails a significant refactor to the API.
Given that we need to cut a new release soon, I've decided to drop support for
older releases for now. We may eventually add them back as a matter of
principle to exercise backwards compatibility, albeit I expect that people are
unlikely to use them again once we drop support for them once.
This also changes `ProtocolVersion` to `StandardVersion` everywhere in the API
and the command line for consistency with the change to the standard, since
there is no longer a protocol version now that we use the standard version to
version everything.
This change drops the dependency on `insert-ordered-containers` in favor of a
new `Dhall.Map` module which implies a limited subset of the functionality we
need. In addition to simplifying the dependency tree this also improves
the performance of the `deep-nested-large-record` benchmark by 2.4x:
Before:
```
time 1.412 s (1.388 s .. 1.436 s)
1.000 R² (1.000 R² .. 1.000 R²)
mean 1.398 s (1.387 s .. 1.404 s)
std dev 10.02 ms (2.502 ms .. 13.39 ms)
variance introduced by outliers: 19% (moderately inflated)
```
After:
```
time 582.2 ms (552.5 ms .. 628.4 ms)
0.999 R² (0.999 R² .. 1.000 R²)
mean 565.9 ms (560.3 ms .. 574.6 ms)
std dev 8.901 ms (1.218 ms .. 11.75 ms)
variance introduced by outliers: 19% (moderately inflated)
```