Commit Graph

1391 Commits

Author SHA1 Message Date
Simon Jakobi
a4b4cfb1b3 infer: Remove redundant checks for field selections and record projections (#1368)
… as pointed out by @MonoidMusician in #741.
2019-10-02 01:41:18 +00:00
Gabriel Gonzalez
75e6cc5ca7 Fix pretty-printing precedence of toMap (#1360)
* Fix pretty-printing precedence of `toMap`

Fixes https://github.com/dhall-lang/dhall-haskell/issues/1358

* Also correctly format `merge` expressions without a type annotation

... as suggested by @sjakobi

* Add test for formatting "function-like" expressions

This verifies that the code correctly handles `toMap` expressions with
type annotations as @sjakobi was asking about
2019-10-01 04:01:22 +00:00
Gabriel Gonzalez
e707db04ec Remove unnecessary type-checking step (#1362)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1361
2019-10-01 02:56:57 +00:00
quasicomputational
24bb8b7fae Allow haskell-lsp 0.16. (#1357)
This is related to #1249, since earlier versions don't support GHC
8.8.
2019-10-01 00:24:15 +00:00
Simon Jakobi
d6d3943fe5 Update type-inference of annotated expressions (#1337)
… as standardized in https://github.com/dhall-lang/dhall-lang/pull/745.

This also adds proper error handling for the free variable case
discussed in https://github.com/dhall-lang/dhall-lang/issues/749:

Sample output for the MergeHandlerFreeVar test case:

    Error: Disallowed handler type

    Explanation: You can ❰merge❱ the alternatives of a union using a record with one
    handler per alternative, like this:

        ┌─────────────────────────────────────────────────────────────────┐
        │ let union    = < Left : Natural | Right : Bool >.Left 2         │
        │ let handlers = { Left = Natural/even, Right = λ(x : Bool) → x } │
        │ in  merge handlers union : Bool                                 │
        └─────────────────────────────────────────────────────────────────┘

    ... but the output type of a handler may not depend on the input value.

    For example, the following expression is not valid:

          Invalid: The output type is ❰Optional A❱, which references the input
          value ❰A❱.
                      ⇩
        ┌──────────────────────────────────────────┐
        │ merge { x = None } (< x : Type >.x Bool) │
        └──────────────────────────────────────────┘

    Your handler for the following alternative:

    ↳ x

    ... has type:

    ↳ ∀(A : Type) → Optional A

    ... where the output type:

    ↳ Optional A

    ... references the handler's input value:

    ↳ A

    ────────────────────────────────────────────────────────────────────────────────

    1│ merge { x = None } (<x: Type>.x Bool)

    dhall/dhall-lang/tests/type-inference/failure/unit/MergeHandlerFreeVar.dhall:1:1
2019-09-29 12:52:41 +00:00
Gabriel Gonzalez
5595801b4e Add dhall lint support for fixing malformed assertions (#1353)
* Add @dhall lint@ support for fixing malformed assertions

* s/==/≡/

... as caught by @sjakobi

Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>
2019-09-28 21:44:12 +00:00
Gabriel Gonzalez
afcca0fa14 Increase upper bounds on dhall-json dependencies (#1352) 2019-09-28 16:07:47 +00:00
Simon Jakobi
7c91dd5f48 Fix Expr's Eq instance via a newtype wrapper for Doubles (#1347)
See the haddocks in Dhall.Core for details.

Fixes #1341.
2019-09-28 14:56:37 +00:00
Gabriel Gonzalez
8abb411f06 Update release script (#1349)
With each new release I'm slowly automating more of the work I do for the
release process.  This change downloads the pre-built Linux binaries
and names them correctly for ease of upload to the release page.
2019-09-26 18:00:58 +00:00
Simon Jakobi
acd5144ef7 dhall repl: Don't normalize inferred types (#1338)
Context: #1300
2019-09-26 17:33:42 +00:00
Simon Jakobi
87f352d66e Fix a type in the nestedReduction test case (#1339) 2019-09-26 16:43:36 +00:00
Simon Jakobi
72bf46b600 Add a Show instance for Val (#1344)
Since Val contains functions, its Show instance cannot be
derived in the usual way without exposing a non-standard Show
instance for (Val a -> Val a). Instead, we rely on the user to
provide a fitting instance, e.g. by importing Text.Show.Functions.
2019-09-26 15:58:51 +00:00
Simon Jakobi
f825dd18d9 Add link to GHC ticket for rounding issue in Integer/toDouble (#1348) 2019-09-26 15:13:43 +00:00
Gabriel Gonzalez
5b136dfa2c
Version 1.26.0 → 1.26.1 (#1336) 2019-09-24 21:14:33 -07:00
Gabriel Gonzalez
328a6739a8 Build against Diff-0.4.* (#1343)
Related to https://github.com/commercialhaskell/stackage/issues/4842
2019-09-25 03:29:02 +00:00
Gabriel Gonzalez
1682c4c5f2 Fix inferred type for record projection (#1342)
This ensures that record projection correctly sorts the fields in the
inferred type

This fixes the regression test in
https://github.com/dhall-lang/dhall-lang/pull/750
2019-09-25 02:34:51 +00:00
Jack Henahan
7080883af3 Make sure dhall-nix is included in releases (#1340)
Saw on Slack that the Darwin release was missing for `dhall-to-nix`, and from what I've dug up it looks like this should fix that.
2019-09-24 14:19:50 -07:00
Javier Neira
08747af8d3 Warn about missing cache directory (#1320)
* Warning action about missing cache dir

* Add warning to executable

* Correct duplicate cacheName in getCacheFile

* Warn if dhall-haskell cache dir is not usable

* Improve warn message

Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>

* Correct plural

Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>

* Improve syntax

Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>

* Use runMaybeT to make 2 step warnings

* Add FlexibleContexts to make happy lts-6

* Catch IOException's when handling cache dir

This make the haskell impl follow the standard.

* Correct unwanted identantion

* Push warnings to get* wrapper functions

* Remove unnecessary lang extension

* Inline warnings in get* functions

* Being consistent with break lines

* Apply suggestions from code review

About phrasing, formatting, syntax, etc

Co-Authored-By: Gabriel Gonzalez <Gabriel439@gmail.com>

* doesPathExist is not in directory-1.2.2.0

* Make message fit in 80 cols
2019-09-24 08:59:58 +00:00
Gabriel Gonzalez
95809b467d
Use Dhall.Eval for type-checking (#1335)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1306

The following comment describe how this works in depth:

https://github.com/dhall-lang/dhall-haskell/issues/1129#issuecomment-532928798

The short explanation is that we can substantially speed up type-checking
by not substituting `let` expressions and instead adding the bound variable
to the context.  This is the same as the type-checking "fast path" that
we had before adding dependent types, except this time it works even in the
presence of dependent types.

The main difference is that we add the `let`-bound type *and* value to the
context and use `Dhall.Eval.conv` to perform equivalence checking instead of
`Dhall.Core.judgmentallyEqual`.
2019-09-22 10:37:26 -07:00
Gabriel Gonzalez
183cc9291a Add --censor flag support for censoring type errors (#1329)
* Add `--censor` flag support for censoring type errors

Fixes https://github.com/dhall-lang/dhall-haskell/issues/1294

* Reuse `censorText`

... as caught by @sjakobi

* Remove `typeWith` refactor

... as caught by @sjakobi

This is a vestige of a refactor that I reverted incompletely

* Reuse `Dhall.Core.censorText` in `Dhall.Parser` module

... as suggested by @sjakobi
2019-09-22 04:44:51 +00:00
Simon Jakobi
b556a65644 Handle --version consistently (#1334)
* dhall --version

* dhall-to-bash --version

* dhall-to-nix --version

* dhall-lsp-server --version
2019-09-22 03:55:26 +00:00
Vanessa McHale
fe748e2884
Dhall version (#1332)
* Add Dhall.Version module

* Add Paths_dhall to Autogen-Modules
2019-09-20 15:53:13 +00:00
Patrick Mylund Nielsen
fa84b0dc19
Different with-http CPP check; fix remote imports in GHCJS (#1330)
Completes the changes in #1311
2019-09-20 10:44:15 -04:00
Simon Jakobi
0ef00bf5e3 Fix running the type-inference failure tests (#1326)
This fixes several bugs introduced in
fddce0b8cf.
2019-09-19 15:46:07 +00:00
Ollie Charles
8ead6012e9 dhall: Support GHC 8.8 (#1324) 2019-09-19 14:14:54 +00:00
Gabriel Gonzalez
54241f88c7 Disable 1-field simplification by default (#1321)
* 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
2019-09-19 07:07:23 +00:00
Simon Jakobi
2fcbf84e2f dhall type: Add --quiet option (#1325)
Closes #1323.
2019-09-19 05:45:39 +00:00
Ryan Scott
62ee6ff249 Give dhall repl's turnstile an ASCII variant (#1327)
This makes `⊢` print as `|-` under `dhall --ascii repl`.
2019-09-18 12:29:08 -07:00
Gabriel Gonzalez
8bced75668 Refactor Dhall.Eval (#1322)
* 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
2019-09-18 00:29:22 +00:00
Javier Neira
cc09c56788 Generate artifact zips only for tags (#1319) 2019-09-17 05:33:49 +00:00
Javier Neira
640913f8d2
Fix default cache handling in windows (#1272)
* Ignore all stack*.yaml.lock files
* Use `$LOCALAPPDATA` environment variable in windows
2019-09-16 09:51:00 +02:00
Simon Jakobi
17c28d4b6c Adjust type inference for record literals (#1309)
… to changes from
https://github.com/dhall-lang/dhall-lang/pull/740.
2019-09-15 20:03:58 +00:00
Gabriel Gonzalez
ca86ed612c Simplify Inject/Interpret for 1-field records (#1315)
* 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
2019-09-15 03:37:42 +00:00
Simon Jakobi
fddce0b8cf Adjust type-checking test setup (#1275)
… in response to https://github.com/dhall-lang/dhall-lang/pull/723.
2019-09-15 02:56:16 +00:00
Simon Jakobi
1fed9063d5 Prevent repl from inserting inferred 'Sort's into context (#1318)
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.
2019-09-15 02:16:26 +00:00
Simon Jakobi
9d4fa51450 dhall type: Don't normalize inferred types (#1317)
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.
2019-09-14 23:31:12 +00:00
Taylor Fausak
8c388c7994 Fix Haddock formatting in dhallFromJSON (#1316) 2019-09-14 13:35:38 -07:00
Gabriel Gonzalez
93943a29c4 Format record fields more compactly if they fit on 1 line (#1314)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1313
2019-09-14 14:10:29 +00:00
Gabriel Gonzalez
79bd32e4b9 Add --censor switch for disabling source code display (#1312)
* 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`
2019-09-14 05:01:23 +00:00
Patrick Mylund Nielsen
c29b128339
Improve GHCJS support (cabal build, SHA256 hashing) (#1311) 2019-09-13 11:42:55 -04:00
Gabriel Gonzalez
272b733e52 Add docker-upload script (#1308)
This is a utility script that I created for updating Docker images for
each release
2019-09-13 04:07:06 +00:00
Simon Jakobi
88c2f29a57
Simplify nested record projections (#1307)
… as standardized in https://github.com/dhall-lang/dhall-lang/pull/729.
2019-09-13 05:38:27 +02:00
Simon Jakobi
796680bb99 Simplify ⫽ within projection (#1283)
… as standardized in https://github.com/dhall-lang/dhall-lang/pull/697.
2019-09-12 11:42:31 +00:00
Gabriel Gonzalez
65710954cf
Version 1.25.0 → 1.26.0 (#1286) 2019-09-11 19:37:25 -07:00
Robbie McMichael
c8402faa37 Minor bug fixes for yaml-to-dhall error messages (#1305)
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`.
2019-09-11 15:05:51 +00:00
Simon Jakobi
23910e70e3 dhall-json: Add --output options (#1304)
As requested in #1303.
2019-09-11 06:05:19 +00:00
Simon Jakobi
cb5ccab636 let-formatting: Insert hardline in front of the '=' instead of behind (#1302)
Fixes #1301.
2019-09-11 05:21:11 +00:00
Gabriel Gonzalez
4458cf04a2 Simplify recursive Interpret instance (#1298)
* 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
2019-09-11 03:24:10 +00:00
Gabriel Gonzalez
70948b3cba
Build against profunctors-5.5.* (#1299) 2019-09-10 18:39:11 -07:00
Simon Jakobi
37f819c8bb
Add --no-cache flag (#1290)
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
2019-09-09 22:37:30 +02:00