Commit Graph

80 Commits

Author SHA1 Message Date
Gabriel Gonzalez
8f3e913cde
Use git submodule to obtain official Prelude and test suite (#787)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/766
2019-01-19 09:09:34 -08:00
Gabriel Gonzalez
96d34ee92a
Don't disable -fwarn-incomplete-uni-patterns at module level (#784)
... as suggested by @ocharles in
c368d66a6f (commitcomment-31973007)

Instead, explicitly opt out more narrowly with `unsafeExpect*` functions
2019-01-18 07:13:49 -08:00
Gabriel Gonzalez
f24f665047
Fix non-exhaustive pattern match in dhall lint (#780)
`dhall lint` would fail on the following expression:

```
    let replicate = https://prelude.dhall-lang.org/List/replicate

in  let Config = { name : Text, age : Natural }

in  let Configs = List Config

in  replicate 10 Text "!"
```

... because the code (incorrectly) assumed that simplifying an inner
`let` binding would preserve at least one `let` binding.  However, when the
outer `let` (beginning with `let replicate`) is simplified the inner `let`
(beginning with `let Config`) simplifies down to just `replicate 10 Text "!"`
which has no `let` binding at all, leading to a pattern match failure.

This change fixes that by extending the code to correctly handle that case
with an exhaustive pattern match.
2019-01-16 21:59:11 -08:00
Gabriel Gonzalez
aed91b3b44
Fix parsing of list annotations (#779)
Related to: https://github.com/dhall-lang/dhall-lang/issues/343

According to the standard a non-empty list with a type annotation should
not be encoded with the type annotation alongside the list elements.  The
type annotation should be parsed and encoded as a separate constructor.
2019-01-16 20:28:12 -08:00
Gabriel Gonzalez
3a315225d7
Build against http-client-0.6 (#776)
Related to https://github.com/commercialhaskell/stackage/issues/4290
2019-01-16 20:09:37 -08:00
Gabriel Gonzalez
f5928e4472
Fix Nix build to reinstate -Werror (#781)
A refactor of the Nix build accidentally removed the `-Werror` flag, which
caused some warnings to get past CI.  This change fixes that and removes the
warnings.
2019-01-16 19:39:51 -08:00
Javier Neira
3f004ff9bb Fix test errors in windows caused by encoding (#782) 2019-01-16 19:15:57 -08:00
Justin Le
ec48c20f04 UnionType and UnionInputType, analogues of RecordType and RecordInputType (#775) 2019-01-15 16:55:56 -08:00
Javier Neira
d481f47bed Add eta support and update stack config to lts-13 (#778) 2019-01-11 19:35:39 -08:00
Gabriel Gonzalez
162dde95ac
Add inputNormalizer field to InterpretOptions (#777)
This fixes the problem found in https://github.com/dhall-lang/dhall-lang/issues/166#issuecomment-452766374

This ensures that the functions marshalled into Haskell can correctly take
advantage of user-supplied language extensions
2019-01-11 08:29:40 -08:00
Gabriel Gonzalez
fc3472d085
Version 1.20.0 → 1.20.1 (#773) 2019-01-05 18:51:33 -08:00
Nicholas Scheel
78ca289335 Update standard version to 5.0.0 in Binary.hs (#771) 2018-12-31 10:48:17 -06:00
Gabriel Gonzalez
6a70f133a1
Version 1.19.1 → 1.20.0 (#767) 2018-12-29 11:48:21 -06:00
Basile Henry
528ea42407 Fix error message for not-equal when type checking (#768)
According to the standard https://github.com/dhall-lang/dhall-lang/blob/master/standard/dhall.abnf\#L399 the correct operator is `!=`
2018-12-28 13:47:11 -06:00
Gabriel Gonzalez
0b3fd4b624
Prenormalize substituted expressions (#765)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/764

This pre-normalizes expressions before substituting them to
avoid duplicated work.  This also fixes the space leak from the
above issue.
2018-12-24 09:35:56 -06:00
Gabriel Gonzalez
ca78d7977d
Fix type-checking bug for unions (#763)
The Haskell implementation was not matching the specification for
type-checking union types:

* The inferred type of union types was (incorrectly) always returning `Type`
* Unions of mixed alternative types were not being properly rejected

I also discovered several mistakes in the error messages, which I fixed along
the way.
2018-12-22 08:39:26 -06:00
Adam Sandberg Eriksson
026db247f7 Fix haddock syntax (#761) 2018-12-19 07:19:07 -08:00
Gabriel Gonzalez
615eccb10d
Expand main page with high-level reasons to adopt Dhall (#754)
This adds four new sections to the page after the live demo which highlight
the common themes that I notice people use when communicating the value of
Dhall to others on social media:

* The first section emphasizes the element of delight in using the language for
  people who are into elegance and quality

* The second section focuses on more pragmatic people who are sick of YAML and
  just want a reasonable alternative that they can convince their manager to
  adopt

* The third section appeals to the LangSec crowd that wants an uncompromising
  and secure foundation for what they are buliding

* The last section targeted at the skeptic who thinks that Dhall is an ivory
  tower language not suited for real-world problems.

The second crowd (YAML emigrants) is the audience that I'm targeting the
most strongly at the moment, but I didn't want to lead with a negative reason
adopt by focusing on the limitations of YAML, so I put the section on delight
first so that we could start with a more positive tone.
2018-12-13 06:44:33 -08:00
Gabriel Gonzalez
d7d8139d39
Expand "Try dhall" into dhall-lang.org home page (#747)
This expands the "Try dhall" page to serve as a functional home page for
"dhall-lang.org" in the short term by making the following changes:

* Adding a navigation bar to the top that links to useful resources and
  official integrations
* Adding a quick summary explaining what Dhall is
2018-12-10 12:28:19 -08:00
Fintan Halpenny
a95acd5b2a Add Unordered Map Traversal (#749) 2018-12-10 10:46:46 -08:00
Gabriel Gonzalez
2a30c7f4fc
Update binary encoding/decoding for imports (#728)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/308

This adds support for encoding/decoding custom headers and integrity checks.
2018-12-08 10:25:07 -08:00
Gabriel Gonzalez
6ab5df4d49
Implement standardized support for multi-line literals (#726)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/307

Note that this a breaking change because:

* Newlines are now mandatory after the opening `''` of a multi-line
  literal
* The spaces before the trailing `''` count towards the leading
  indentation computation
2018-12-08 08:49:08 -08:00
Georges Dubus
f308ca29b0 Fix diff so that an empty list is equal to itself (#740)
* Test with QuickCheck that an expression is always the same as itself

I noticed cases where the diffing code returns that an expression is not the
same as itself (for example, an empty list). This commit adds a QuickCheck test
to illustrate it, and maybe other cases.

Sadly, I had to expose some internals from Dhall.Diff for the test, which makes
the interface less nice.

* Fix diff so that an empty list is the same as itself
2018-12-07 09:07:47 -08:00
Gabriel Gonzalez
cf69f5a953
Add "Try Dhall" project (#739)
This adds three new Nix build products:

* `try-dhall-static` - The static assets for "Try Dhall"
* `try-dhall-server` - A script which serves the static assets for local
   debugging
* `tarball-try-dhall` - A tarball of the static assets

This is powered by a new small `dhall-try` package which is also included
in this change.
2018-12-06 18:00:03 -08:00
Gabriel Gonzalez
83c4a32e99
Refactor test suite (#733)
This moves all of the test suite modules underneath a `Dhall.Test`
module hierarchy instead of clobbering the top-level namespace.
2018-12-03 09:17:53 -08:00
Gabriel Gonzalez
9148b35aba
Build against tasty-1.2 (#731)
Related to https://github.com/commercialhaskell/stackage/issues/4196
2018-12-03 08:48:43 -08:00
Gabriel Gonzalez
7dd6b76d04
Update READMEs (#732)
This updates all of the `README`s to:

* centralize all of the build/install/develop information in the
  top-level `README`
* get the nested `README`s to use a consistent style
2018-12-03 08:30:30 -08:00
Basile Henry
fa9cbff5ad
Autocomplete for dhall repl (#727)
* Autocomplete repl commands

* Autocomplete imports (file and environment)

* Improve autocomplete separators

* Autocomplete records fields

* Remove use of TypeApplications

* Improve file path completion

* Autocomplete union alternatives

* Import missing (<>)

* Improve parsing of assignment in repl commands

* Remove no-longer-used `foldl'`

* Fix record field autocomplete and improve command autocomplete

* Fix definition order in repl environment

* Autocomplete variables in scope and all reserved identifiers
2018-12-02 19:26:43 +01:00
Gabriel Gonzalez
56d795dfe0
Change how dhall repl handles prior definitions (#729)
The motivation for this change is so that more code type-checks
within a REPL session.

For example, before this change the following session fails:

```haskell
⊢ :let Either = λ(a : Type) → λ(b : Type) → < Left : a | Right : b >
⊢ :let Example = < Left : Natural | Right : Bool >

Example : Type

⊢ Example.Left

Example : Type

Error: Not a record or a union

Example.Left
(stdin):1:1
```

After this change, the same session works:

```
[⊢ :let Example = < Left : Natural | Right : Bool >

Example : Type

⊢ Example.Left

λ(Left : Natural) → < Left = Left | Right : Bool >

```

The difference is in how we incorporate prior definitions when
type-checking code.  Before this change prior definitions were added
to the context, which leads to type-checking failures because type
synonyms don't work when used in this way.  After this change we
incorporate them as extra `let` definitions (same as normalization).
2018-12-02 05:25:21 -08:00
Kevin Wallace
bafab770fd Add :quit repl command (#719)
* Prefer `throwIO` to `throw`
2018-11-29 07:30:15 -08:00
Gabriel Gonzalez
abdd442814
Restore Parent constructor for Local (#718)
This is essentially a revert of 25d86e8e5d

The primary motivation for this is so that paths beginning with `../`
don't get reformatted to begin `./../`.

The secondary motivation for this is to more closely match the standard.
There are fewer special cases in the logic if there is a dedicated
constructor for the `Parent` case.
2018-11-28 19:30:38 -08:00
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
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
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
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