Commit Graph

26 Commits

Author SHA1 Message Date
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
Javier Neira
3f004ff9bb Fix test errors in windows caused by encoding (#782) 2019-01-16 19:15:57 -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
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
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
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
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
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
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
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
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
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
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