Commit Graph

798 Commits

Author SHA1 Message Date
Gabriel Gonzalez
bfda055420
Add encoding/decoding logic for as Text (#712)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/303
2018-11-28 18:10:04 -08:00
Gabriel Gonzalez
a671e9c2f5
Add --json flag for dhall {decode,encode} (#717)
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.
2018-11-28 17:51:20 -08:00
Gabriel Gonzalez
103e2e637a
Add dhall lint support for removing constructors (#701)
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.
2018-11-27 14:32:33 -08:00
Gabriel Gonzalez
92a68efcd3
Add support for records of records of types (#700)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/300

Fixes https://github.com/dhall-lang/dhall-haskell/issues/692
2018-11-27 13:36:15 -08:00
Fintan Halpenny
5a0d671f95 constructors === id (#693) 2018-11-27 11:53:20 -08:00
Gabriel Gonzalez
04e2dbfcaa
Version 1.19.0 → 1.19.1 (#705) 2018-11-27 00:09:00 -08:00
Gabriel Gonzalez
653932e112
Simplify import error handling logic (#711)
The first two cases of the `handler₀` function are just special cases
of the last case
2018-11-26 23:36:46 -08:00
Basile Henry
65f5377f0c
Unique dependencies in dot graph (#713)
* Add dotgen to stack.yaml

* Generate strict dot graph (prune redundant connections)
2018-11-26 17:19:02 +01:00
Gabriel Gonzalez
85ccf2ff0a
Improve HTTP error messages (#710)
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.
2018-11-26 07:53:22 -08:00
Basile Henry
c8dc585430
Generate dot graph to visualize import graph (#698)
* 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
2018-11-26 07:24:20 +02:00
Gabriel Gonzalez
8fd846bf46
Fix CHANGELOG to mention new alternative to constructors (#696)
... as caught by @jneira
2018-11-24 09:37:30 -08:00
Gabriel Gonzalez
99fabea38a
Fix import caching (#702)
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.
2018-11-24 08:52:30 -08:00
Justin Woo
f3d26e5f32 add --version to dhall-json (#704) 2018-11-24 08:35:58 -08:00
Gabriel Gonzalez
203a22818e
Fix bug when linting multi-let expressions (#703)
`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`
2018-11-24 08:32:04 -08:00
Gabriel Gonzalez
c71f0e28fc
Fix dhall-bash version to 1.0.17 (#695)
I forgot to bump the version number for `dhall-bash` in #691, which this
change fixes
2018-11-21 19:30:03 -08:00
Gabriel Gonzalez
53ae87c8e2
Version 1.18.0 → 1.19.0 (#691) 2018-11-21 19:10:32 -08:00
Gabriel Gonzalez
bacb82480c
Fixed mixed field access (#694)
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.
2018-11-21 18:31:55 -08:00
Gabriel Gonzalez
8bc595be7f
Add support for quoted path components (#690)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/293
2018-11-20 18:08:43 -08:00
David Virgilio
adf94a6503 Encode doubles as Double, do bounds checks, and add support for NaN and Infinity values (#667) 2018-11-20 15:07:08 -08:00
Gabriel Gonzalez
5b2ee41386
Build against yaml-0.11.0.0 (#689) 2018-11-17 08:28:06 -08:00
Gabriel Gonzalez
8a74105007
Update tests to match the filesystem layout from the standard (#688)
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.
2018-11-17 08:23:26 -08:00
Gabriel Gonzalez
96a360a5bc
Add lower bound to optparse-applicative (#685)
Fixes https://github.com/dhall-lang/dhall-lang/issues/282
2018-11-16 08:43:23 -08:00
Gabriel Gonzalez
ef7c0681ca
Run tests in CI (#686)
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`.
2018-11-16 08:20:31 -08:00
Gabriel Gonzalez
3ed5f4d293
Prevent Hurkens' paradox (#680)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/272
2018-11-15 19:49:57 -08:00
Oliver Charles
9d3e493f69 Allow custom normalization to be entered top-down (#684) 2018-11-15 18:25:30 -08:00
Gabriel Gonzalez
8a5bfaa3b9
Add support for multi-let (#675)
... as standardized in: https://github.com/dhall-lang/dhall-lang/pull/266

This also adds `dhall lint` support for consolidating nested `let` expressions
2018-11-13 08:01:59 -08:00
Gabriel Gonzalez
b3968f681a
Preserve Unicode characters (#679)
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.
2018-11-12 09:46:33 -08:00
Javier Neira
5db1051311 Update stack/cabal config to sync with new structure (#671)
Also, add build instructions for cabal and stack in alphabetical order
2018-11-06 05:42:23 -08:00
Dan Burton
9d39286e35 Test that formatting preserves projection order (#672) 2018-11-05 21:37:10 -08:00
Alexander Biehl
096c03936e Introduce normalizeWithM for monadic normalization (#371) 2018-11-05 20:21:29 -08:00
Dan Burton
7aba79118c Use an Ordered Set for Project (#670) 2018-11-05 19:59:01 -08:00
Gabriel Gonzalez
dc5493d87f
Test build against ghc-8.6 (#669)
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
2018-11-03 07:27:12 -07:00
Sofia Rose
9d0fd42d95 Fix parsing of //\\ (#666)
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 \\.
2018-10-29 20:28:50 -07:00
Gabriel Gonzalez
aecfbc9acc
Migrate dhall-{bash,json,text} into this repository (#661)
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`.
2018-10-28 17:32:51 -07:00
Oliver Charles
6fd4c83724 Add subExpressions Traversal (#660)
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.
2018-10-26 16:35:45 -07:00
Gabriel Gonzalez
84c99bf988
Fix parsing of the Some keyword (#658)
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`.
2018-10-26 08:48:34 -07:00
Fintan Halpenny
8cad992639
Union Access (#657)
Addressing phase 1 of https://github.com/dhall-lang/dhall-lang/issues/244 and https://github.com/dhall-lang/dhall-haskell/issues/635 

@Gabriel439: I haven't implemented any tests for this and I should but is there documentation of how the tests are laid out? I'm slightly confused but possibly it'd be fine if I spent some more time looking through them :)
2018-10-26 11:07:11 +01:00
Gabriel Gonzalez
01d6cad27f
Update README and Nix logic (#650)
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
2018-10-20 09:27:16 -07:00
Fintan Halpenny
29544a4671 Doc should be Prefer (#649) 2018-10-19 07:07:10 -07:00
Gabriel Gonzalez
c40eadd577
Adjust license to a format GitHub recognizes (#644)
Fixes #643
2018-10-18 19:19:38 -07:00
Gabriel Gonzalez
dbe8d7a21c
Version 1.17.0 → 1.18.0 (#636) 2018-10-15 21:08:44 -07:00
Greg Pfeil
2010d410ee
Add kind polymorphism. (#563)
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
  }
```
2018-10-15 10:22:21 -06:00
Gabriel Gonzalez
25a0d69797
Import Prelude instead of vendoring the Prelude (#639)
This uses Dhall's import system to fetch the Prelude so that we don't have
to keep a local copy of it
2018-10-14 09:00:08 -07:00
Gabriel Gonzalez
88b406b30c
Change dhall freeze to support refreezing imports (#637)
Fixes: https://github.com/dhall-lang/dhall-haskell/issues/630

`dhall freeze` will now refreeze existing imports if they have a bad semantic integrity check
2018-10-14 08:17:27 -07:00
Gabriel Gonzalez
fcfae0c6dd
Fix dhall repl commands (#638)
`repline` requires you to specify the leading character for commands now,
otherwise it disables support for commands
2018-10-13 15:45:04 -07:00
Gabriel Gonzalez
d9713ca54c
Support standard version 3.0.0 and drop support for older versions (#634)
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.
2018-10-12 14:00:10 -07:00
Gabriel Gonzalez
afffa17be4
Add IsList instance for Dhall.Map.Map (#624)
`dhall-json` needs this so that it can pattern match on a `Map` as a list
of key-value pairs
2018-10-11 19:47:30 -07:00
David Virgilio
87aa062b85 Fix parse error for IPv4-mapped IPv6 addresses (#632) 2018-10-11 13:08:49 -07:00
Fintan Halpenny
f4a65634c3 dhall freeze adds a final newline (#629) 2018-10-10 10:14:51 -07:00
Gabriel Gonzalez
3737b6feca
Add new Dhall.Map module (#612)
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)
```
2018-10-06 10:44:40 -07:00