Commit Graph

1149 Commits

Author SHA1 Message Date
Javier Neira
1d3f3d32fe [dhall-json] Isolate yaml usage behind Dhall.Yaml (#989) 2019-06-05 08:01:55 -07:00
Frederik Ramcke
49d29d685f
dhall-lsp-server: Rework diagnostics backend + detailed error messages on hover (#982)
* Refactor Diagnostics backend

This commits refactors Backend.Dhall.Diagnostics, cleaning things up and
adding comments along the way. We also lose Backend.Dhall.DhallErrors.

The user-facing result is a step backwards, as we revert to using Dhall's
Show instances to print errors, which gives us error messages that don't
fit the LSP use case very well at the moment. In the future
we should change Dhall's error printing API (the Show instances) to make
them more generally useful (in particular for the LSP use case), thus
saving us from having to duplicate code (as was previously did, when
dhall-lsp-server was not yet part of the upstream project).

* Proof of concept: Provide detailed error messages

This proof of concept provides detailed explanations on hovering over type
errors. Currently this is done by injecting the explanation directly into
the hover text, which 1. conflicts with the short error messages, which
are still being displayed at the same time and 2. is not particularly
readable, since the explanations are meant to be rendered at least 80
characters wide.

For future work I am planning to instead only add an "explain" link to the
hover window, which when clicked opens the explanation in a separate
window (inspired by how the haskell ide engine presents documentation
links). This will require a small amount of client-side logic.

* Explain error messages via VSCode Command URIs

The first proof of concept simply spit out the explanations as hover text;
in order to make the feature a bit more useful, we now encode the
explanation text into a VSCode command URI (that still needs to be
implemented client-side), so that upon hovering over an error the user is
presented with a clickable "Explain error message" link.

The feature is still in the prototype stage!

* Use custom URI scheme instead of command URIs

Use URIs of the form "dhall-explain:?text" to present detailed
explanations on hovering. Previously we used command URIs, which are
specific to VSCode.

Needs a correspondingly patched vscode-lsp-server to handle the
"dhall-explain" URI scheme.

* Fix handling of relative imports in diagnostics

In refactoring the diagnostics backend I forgot to initialise the settings
passed to the Dhall type-checker, which are needed to properly resolve
relative imports. An easy fix for a silly mistake ;)

* Remove outdated TODO comment

* Make GHC stricter when building dhall-lsp-server

Add -Wall and -fwarn-incomplete-uni-patterns to the GHC options when
building dhall-lsp-server. This brings it in line with the rest of
dhall-haskell.

* Fix warnings when building dhall-lsp-server

* Fix review comments

Fixes Gabriel's PR comments. Note that I leave a proper fix to
DhallException for the future (I want to work on something else for a bit
;)).

* Use underscores to pacify warnings
2019-06-04 16:48:06 +00:00
Gabriel Gonzalez
98c7d4dfca
Support older yaml versions (#981)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/969
2019-06-02 14:16:47 -07:00
Gabriel Gonzalez
e8ac5e3bd0
Add new --cache flag to dhall freeze (#980)
Part of https://github.com/dhall-lang/dhall-lang/issues/563

This flag freezes imports in the same way as the Prelude by providing a
fallback unprotected import without an integrity check.  The primary use
case for this is caching imports with a graceful fallback, which is why
the flag is named `--cache`
2019-06-01 09:44:01 -07:00
Gabriel Gonzalez
8dc52fa3d2
Add support for improved using behavior (#967)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/560
2019-06-01 08:27:26 -07:00
Javier Neira
2a37b2e7bf Bump up lower bound of aeson-pretty (#978) 2019-06-01 07:10:38 -07:00
Gabriel Gonzalez
7410f8d3bd
Update to latest version of standard (#976) 2019-05-30 22:40:05 -07:00
Robbie McMichael
6ec28cda27 Use json-to-dhall to implement yaml-to-dhall (#977) 2019-05-30 08:54:35 -07:00
Frederik Ramcke
7ba33437e2 Fix LSP diagnostics to trailing whitespace (#974)
* dhall-lsp-server: Revert from Relude to standard Prelude

The code so far used Relude in place of the standard Prelude. Reverting
back to the standard Prelude brings dhall-lsp-server in line with the
rest of the dhall-haskell family, while also reducing the barrier to
contribution.

This change causes a number of additional explicit imports; creating a
"Library" module to gather the common imports could perhaps solve both
problems, i.e. reducing overhead while not having to resort to a custom
prelude. (This is left for a future refactoring.)

*  dhall-lsp-server: Exclude trailing whitespace in diagnostics

Dhall's current parser includes trailing whitespace in source range
annotations. Until now, we simply passed these "loose" ranges on to the
LSP client when generating diagnostic messages; this behaviour is fixed
in the present commit.

Previously (assuming funcTion is misspelled):
 funcTion argument
 ~~~~~~~~~

Now:
  funcTion argument
  ~~~~~~~~

* Refactor lines' to return NonEmpty list

Thanks to Gabriel for pointing this out! Since "lines'" always returns at
least a singleton list containing the empty line we can reflect this in
its type; this allows us to get rid of a test for non-emptiness in
"offsetToPosition".
2019-05-29 14:38:02 -07:00
Gabriel Gonzalez
3c08c627e8
Support projection by record type (#958)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/499
2019-05-27 20:54:42 -07:00
Valery V. Vorotyntsev
6d363ce734 Dhall.Tutorial: fix shell output formatting (#972)
Fixes #971
2019-05-27 20:05:27 -07:00
Gabriel Gonzalez
a9bacbecfe
Add :clear command to dhall repl (#966)
Fixes #860
2019-05-24 09:39:19 -07:00
Gabriel Gonzalez
411726a3eb
Reject wrong type annotation for record/union literals/types (#965)
Fixes #959
2019-05-23 08:37:19 -07:00
quasicomputational
f61a3f2fb1
dhall-json: fix yaml dependency. (#962)
In yaml-0.11, Text.Libyaml was split into the libyaml package. Hence,
as dhall-json imports that module, a libyaml dependency is needed when
yaml >= 0.11. This necessitates an automatic flag.
2019-05-23 13:27:41 +01:00
quasicomputational
c9df4d4e47 dhall: fix the dhall-command benchmark. (#964)
Seems that Main.Default changed in #949, but this use-site wasn't
changed at the same time.
2019-05-22 20:43:16 -07:00
quasicomputational
6791341c27 dhall-lsp-server: add tasty-discover to build-tool-depends. (#963)
The test-suite uses the executable at build-time. New-style
cabal-install requires it to be mentioned in build-tool-depends.
2019-05-22 19:19:13 -07:00
quasicomputational
d77e174ab7 CPP out Monad.fail definition. (#961)
As Dhall's bounds don't allow base 4.13, this doesn't actually affect
anyone running in a supported configuration (i.e., without
--allow-newer). Further note that base 4.13 (i.e., GHC 8.8) isn't
tested in CI at present.

This could well be the last GHC 8.8-related change needed to
code (bounds will definitely need to be adjusted). In this case, a
Dhall release with relaxed bounds will suffice to finish off GHC 8.8
support.

However, it's also possible that dependencies might bundle together
breaking changes with 8.8 support, in which case adaptations will
still need to be made.
2019-05-22 18:48:31 -07:00
Gabriel Gonzalez
699cbf9020
Fix broken link (#953)
Fixes https://discourse.dhall-lang.org/t/broken-link-on-dhall-lang-org/87

... as caught by @philandstuff
2019-05-15 20:26:00 -07:00
quasicomputational
7e6ac01810 Add chunkExprs. (#954) 2019-05-15 08:51:31 -07:00
Gabriel Gonzalez
0bbfe6f14c
Move customization documentation into Haskell package (#951)
Related to https://github.com/dhall-lang/dhall-lang/issues/544
2019-05-14 17:55:15 -07:00
Greg Pfeil
de8e7639df Fix diff output to not double-print key-value separators. (#952)
E.g.,
```
{ unit :   …
```
was being printed as
```
{ unit : :   …
```
2019-05-14 08:00:02 -07:00
Gabriel Gonzalez
89817b41fd
Build docker images for each package in CI (#950)
Fixes #513
2019-05-13 10:37:03 -07:00
Gabriel Gonzalez
20f6d8c316
Add --file flag (#949)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/882

This allows users to supply the Dhall expression by path instead of via
standard input.  This also ensures that transitive imports are resolved
appropriately relative to the file's path.

In other words, instead of this:

```
$ dhall <<< './foo/bar.dhall'
```

Users can now do:

```
$ dhall --file foo/bar.dhall
```
2019-05-13 09:26:38 -07:00
Gabriel Gonzalez
d788b780a2
Update to latest version of language standard (#948)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/947
2019-05-13 08:23:46 -07:00
Gabriel Gonzalez
dadade9dd8
Fix linting tests to only test linting (#945)
The tests were unnecessarily attempting to resolve imports, which is
orthogonal to linting
2019-05-13 07:01:04 -07:00
Gabriel Gonzalez
8139c3678c
Change YAML/JSON encoding for NaN/Infinity/-Infinity (#946)
Before, `dhall-to-json`/`dhall-to-yaml` would use approximate
representations for special `Double` values.  Specifically, `NaN`
would encode as `null` and `±Infinity` would encode as the minimum
and maximum `Double` values.

After this change, YAML will now use `nan`/`inf`/`-inf` to encode
these values (since special `Double` values are natively supported
by YAML) and the JSON encoding will reject them by default.  The
user can restore the old behavior for the JSON encoding by enabling
the `--approximate-special-doubles` flag.
2019-05-12 16:04:25 -07:00
Dmitry Dolgov
07906673af [POC] Add 'quoted' option (#941)
Allow to generare quoted scalars if needed via providing a custom encode
options to Data.Yaml.encodeWith. So far two corner cases from yaml
itself (an empty scalar, and special strings) are omitted in the
implementation.
2019-05-12 07:44:12 -07:00
Gabriel Gonzalez
bf4349ef7a
Version 1.22.0 → 1.23.0 (#943) 2019-05-11 13:03:42 -07:00
Robbie McMichael
2530207abb Set syntax highlighting for Dhall files (#942) 2019-05-07 09:13:19 -07:00
quasicomputational
48c73f3ef9 Add and expose genericInject. (#940)
This is a counterpart to `genericAuto`, which is useful for dealing
with types coming from a library without orphan instances.
2019-05-05 20:21:50 -07:00
Gabriel Gonzalez
7d56778350
Fix another α-normalization bug (#938)
This was caught by the following test:

372230d161/tests/alpha-normalization/success/unit/FunctionNestedBindingXXFreeA.dhall
2019-05-05 19:30:26 -07:00
Stephen Paul Weber
2fc7f79959 Reduce dependency requirements to what is in sid (#939)
This make it easier to build the package on debian unstable, which is
the first step towards an official package.
2019-05-05 07:54:14 -07:00
Gabriel Gonzalez
a929d4e0bb
Fix marshalling of unions (including enums) in and out of Dhall (#936)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/930
2019-05-04 22:29:51 -07:00
Basile Henry
29ccd7d0cb Fix repl autocomplete for Records and Unions (#937) 2019-05-04 12:13:09 -07:00
klntsky
74fcafe5d3 dhall freeze subcommand should respect --ascii flag (#934)
Fixes #877
2019-05-03 13:44:59 -07:00
Greg Pfeil
1073d04b82 Fix merging of sort-level record types. (#891)
Fixes #890
2019-05-03 08:50:23 -07:00
AndrasKovacs
931dc50522 Fix alpha normalization (#931)
Fixes #929
2019-05-02 13:50:17 -07:00
quasicomputational
c9ea8b99ca Teach genericAuto about new-style union construction. (#927)
The underlying bug is very similar to #915, and in fact this builds on
the fix for that in #918.

Closes #926.
2019-05-02 09:26:53 -07:00
Vanessa McHale
8fa233336d Add 'cross' flag to simplify cross-compilation (#928)
Co-Authored-By: vmchale <vmchale@users.noreply.github.com>
2019-05-02 08:21:39 -07:00
quasicomputational
66df01b26c
Remove stack-lts-11.yaml. (#922)
It had bitrotted and wasn't presently building; evidently no-one was
missing it. LTS 6 is actively checked by CI, so while this loses some
coverage of dependency versions in the middle of the range, it doesn't
shrink the overall range of dependencies tested.

Closes #921.
2019-05-01 20:40:13 +01:00
quasicomputational
4f9defec25 Use MonadFail.fail, not Monad.fail. (#912)
Monad.fail is no more with GHC 8.8, so this is a forced change.
However, it will also work on older GHCs.
2019-05-01 11:22:39 -07:00
klntsky
962a172b53
Converted sample code to doctest for RecordType, UnionInputType, RecordInputType 2019-05-01 09:52:43 +03:00
Gabriel Gonzalez
6d510ee2b1
Add line numbers to error messages (#919)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/905

For example, this file:

```haskell
[ 1
, 2
, 3
, Bool

+ 1
]
```

... now produces this error message:

```
Use "dhall --explain" for detailed errors

↳ ./example.dhall

Error: ❰+❱ only works on ❰Natural❱s

4:   Bool
5:
6:
7:
8:
9: + 1

/Users/gabriel/proj/dhall-haskell/dhall/example.dhall:4:3
```
2019-04-30 15:31:18 -07:00
Gabriel Gonzalez
d69ac6599f
Fix CHANGELOG for version 1.22.0 (#917)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/914

This mentions breaking changes that were part of implementing verison 7.0.0
of the standard
2019-04-30 12:13:22 -07:00
Gabriel Gonzalez
d1501b51f9
Increase lines of context for error messages (#916)
Related to https://github.com/dhall-lang/dhall-haskell/issues/905

This increases the size of expressions that we display in error messages to
20 on each side before we begin truncating the output
2019-04-30 10:55:00 -07:00
Gabriel Gonzalez
684cbac7be
Uncomment line from .cabal file (#909) 2019-04-30 09:31:54 -07:00
Gabriel Gonzalez
07c9c62af3
Fix marshaling new-style union literals (#918)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/915
2019-04-30 08:18:12 -07:00
Gabriel Gonzalez
44a2750ca0
Explain use case for dhall-to-nix (#913)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/902
2019-04-27 21:10:02 -07:00
Gabriel Gonzalez
f7fecda09d
Version 1.21.0 → 1.22.0 (#910) 2019-04-27 20:17:34 -07:00
Ollie Charles
d3d7baf3e5
dhall-nix: Fix field-based union access (#907)
Fixes #906.

This adds new translation rules:

* <Foo : {} | Bar>.Foo => x: { Bar, Foo }: Foo x

* <Foo : {} | Bar>.Foo {=} => { Bar, Foo }: Foo {}

* <Foo : {} | Bar>.Bar => { Bar, Foo }: Bar
2019-04-27 11:17:01 +01:00