Commit Graph

1391 Commits

Author SHA1 Message Date
Simon Jakobi
416160b29a Fix formatting of POSIX env vars (#1552)
Fixes #1468.
2019-11-17 03:13:16 +00:00
SiriusStarr
d4050aef27 Correct validation of unicode escapes (#1549) 2019-11-16 12:56:54 -08:00
Simon Jakobi
f18ec5f8e0 Dhall.Pretty.layout: Add comment regarding whitespace stripping (#1538) 2019-11-14 19:02:46 +00:00
Simon Jakobi
53320c8e19 Add regression tests for #1400 (#1536)
Fixes #1400.
2019-11-14 16:11:51 +00:00
Simon Jakobi
dedd5e0ea6
Strip trailing whitespace (#1422)
This raises the lower bound on prettyprinter to 1.5.1 since
`removeTrailingWhitespace` is buggy in earlier versions.

This jailbreaks hnix, which isn't compatible with prettyprinter-1.5.1 yet.

Fixes #183, #1400, #1525. 

Co-authored-by: Gabriel Gonzalez <Gabriel439@gmail.com>
2019-11-14 14:43:35 +01:00
Frederik Ramcke
12ca71f0c7 dhall-lsp-server: Add option to only use ASCII when formatting and linting (#1533)
* Add config support

The config so far consists of a single `asciiOnly` flag (whose intended
behaviour is not yet implemented).

* Implement 'ascii-only' option when formatting and linting

This commit adds functionality to the 'asciiOnly' flag, i.e. when turned
on we don't output fancy non-ascii characters. Needs a recent version of
the client to function -- the version on the marketplace does not relay
configuration data to the server yet!
2019-11-14 05:08:05 +00:00
Gabriel Gonzalez
bd0b2135e5 Make missing referentially transparent (#1509)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/804
2019-11-14 04:41:25 +00:00
Gabriel Gonzalez
db69955356
Add Code of Conduct (#1523)
... based on the [Contributor Covenant](https://www.contributor-covenant.org/)
2019-11-13 19:36:03 -08:00
Gabriel Gonzalez
39aaa86fb9
Revamp dhall-lang.org (#1526)
The main changes are:

* Rework the text substantially to match [the new
  "pitch"](https://discourse.dhall-lang.org/t/more-brainstorming-for-changing-the-dhall-lang-org-landing-page/101/18)
* Add a new "Hash" tab to the live demo
* Use the [new logo](https://github.com/dhall-lang/dhall-lang/pull/803)
2019-11-13 08:34:44 -08:00
Simon Jakobi
cc176e1e93 Simplify the doctest invocation (#1433)
* Simplify the doctest invocation

This doesn't change the number of tests covered.

Fixes #1431.

* Try to fix doctests on Hydra

* Fix doctests with cabal v1-test and try to explain how

* Don't target the Dhall module directly

Dhall.Tutorial already depends on it.
2019-11-13 08:04:05 +00:00
Gabriel Gonzalez
711ee2b00a Add dhall lint support for fixing parent-anchored paths (#1531)
* Add `dhall lint` support for fixing parent-anchored paths

* Fix haddocks to be consistent

... as caught by @sjakobi

Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>
2019-11-12 19:11:05 +00:00
Brian Wignall
5580981599 Fix small typo (#1530) 2019-11-12 13:58:02 +00:00
Gabriel Gonzalez
008a9c3e37 Fix parser for expressions with nested annotations (#1527)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1467

We now no longer replace an annotation if one was already present
2019-11-11 20:43:29 +00:00
Gabriel Gonzalez
a0c3be9ca1 Fix import resolution performance regression (#1522)
* Fix import resolution performance regression

Related to https://github.com/dhall-lang/dhall-haskell/issues/1511

This fixes a performance regression introduced in #1159 where `newManager`
was being called on every remote import.  This fixes that by going back to
caching the `Manager` created by the first request.

This leads to *dramatic* performance improvements for import-rich packages
(like the Prelude or `dhall-kubernetes`) on the first import.  For example,
here are the performance numbers for importing the Prelude for a cold cache
before and after this change:

Before:

```
$ XDG_CACHE_HOME=.cache time dhall hash <<< 'https://prelude.dhall-lang.org/package.dhall'
sha256:99462c205117931c0919f155a6046aec140c70fb8876d208c7c77027ab19c2fa
       64.10 real        10.83 user         2.73 sys
```

After:

```
$ XDG_CACHE_HOME=.cache2 time dhall hash <<< 'https://prelude.dhall-lang.org/package.dhall'
sha256:99462c205117931c0919f155a6046aec140c70fb8876d208c7c77027ab19c2fa
        4.39 real         0.49 user         0.15 sys
```

That's ~16x faster!

The improvement for `dhall-kubernetes` is smaller, but still significant:

Before:

```
$ XDG_CACHE_HOME=.cache3 time dhall hash <<< ~/proj/dhall-kubernetes-charts/stable/jenkins/index.dhall
sha256:04ebd960f6af331c49c3ccaedb353ac8269032b54fe0a29bd167febcd7104d4f
      833.59 real       145.36 user        36.16 sys

After:

```
$ XDG_CACHE_HOME=.cache4 time dhall hash <<< ~/proj/dhall-kubernetes-charts/stable/jenkins/index.dhall
sha256:04ebd960f6af331c49c3ccaedb353ac8269032b54fe0a29bd167febcd7104d4f
      381.41 real         8.41 user         1.91 sys
```

... or ~2-3x improvement.

* Fix `-f-with-http` build

* Remove unnecessary `CPP`

... as caught by @sjakobi
2019-11-08 18:58:03 +00:00
Gabriel Gonzalez
6a160dbae9 Including missing field name in short error message (#1519)
* Including missing field name in short error message

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

* Escape reserved labels in the error message

... as suggested by @sjakobi
2019-11-08 03:05:25 +00:00
Gabriel Gonzalez
d9ea71c765 Fix assertions in body of let bindings (#1518)
* Fix assertions in body of `let` bindings

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

* No need to unpack `Binding`
2019-11-07 19:18:57 +00:00
Simon Jakobi
6d0251f0db README: Include Hackage link for dhall-lsp-server (#1520) 2019-11-07 17:48:38 +00:00
Simon Jakobi
cd49b65c23 Move HsYAML-based code to new package dhall-yaml (#1514)
* Shared code for the dhall-to-yaml[-ng] executables stays in dhall-json.
* Shared tests are in dhall-yaml.

Fixes #1435.
2019-11-07 12:11:04 +00:00
Simon Jakobi
e931451a2b Format more text literals as multi-line strings (#1508)
This causes text literals to be formatted as multi-line strings
whenever they contain at least one newline and at least one non-newline
character. "Spacers" like `"\n\n"` continue be formatted as single-line
strings. If the heuristic turns out to be too eager to choose a
multi-line layout, we can refine it later.

This partially addresses #1496.

Also

* update some variable names

* use 80-column "smart" layout consistently
2019-11-04 03:31:49 +00:00
Gabriel Gonzalez
b3b6bb4e1d Partially fix whitespace parsing performance regression (#1512)
* Partially fix whitespace parsing performance regression

This undoes some of the performance regression introduced
in https://github.com/dhall-lang/dhall-haskell/pull/1483

Before #1483:

```
benchmarked Line comment
time                 11.86 ms   (11.69 ms .. 11.98 ms)
                     0.999 R²   (0.999 R² .. 1.000 R²)
mean                 11.84 ms   (11.79 ms .. 11.89 ms)
std dev              129.4 μs   (107.2 μs .. 164.1 μs)

benchmarked Block comment
time                 13.20 ms   (13.00 ms .. 13.41 ms)
                     0.999 R²   (0.998 R² .. 1.000 R²)
mean                 13.59 ms   (13.41 ms .. 13.94 ms)
std dev              600.0 μs   (142.2 μs .. 953.7 μs)
```

After #1483:

```
benchmarked Line comment
time                 288.7 ms   (282.8 ms .. 294.7 ms)
                     1.000 R²   (0.999 R² .. 1.000 R²)
mean                 292.3 ms   (290.8 ms .. 294.6 ms)
std dev              3.156 ms   (2.216 ms .. 4.546 ms)

benchmarked Block comment
time                 286.2 ms   (280.9 ms .. 292.6 ms)
                     0.999 R²   (0.998 R² .. 1.000 R²)
mean                 290.6 ms   (288.3 ms .. 292.9 ms)
std dev              3.875 ms   (2.866 ms .. 5.500 ms)
```

After this change:

```
benchmarked Line comment
time                 61.44 ms   (60.37 ms .. 63.03 ms)
                     0.999 R²   (0.997 R² .. 1.000 R²)
mean                 61.41 ms   (60.74 ms .. 62.25 ms)
std dev              1.341 ms   (945.0 μs .. 1.901 ms)

benchmarked Block comment
time                 61.83 ms   (60.97 ms .. 63.14 ms)
                     0.999 R²   (0.998 R² .. 1.000 R²)
mean                 61.16 ms   (60.33 ms .. 61.85 ms)
std dev              1.396 ms   (1.011 ms .. 1.907 ms)
```

* Correctly parse `https://example.com usingBla`

... as caught by @sjakobi
2019-11-04 02:12:02 +00:00
Simon Jakobi
7eec31d1d7 Parse whitespace more precisely (#1483)
This is preparatory work for #1454.

This also fixes some cases where dhall would previously accept
malformatted inputs.

The changes to dhall-lsp-server are mostly untested. See #1510.

Co-authored-by: Gabriel Gonzalez <Gabriel439@gmail.com>
2019-11-03 19:42:58 +00:00
Gabriel Gonzalez
cc1814be98 Add Dhall.function (#1507)
... which is the non-typeclass version of the `Interpret` instance for
`a -> b`
2019-11-02 04:36:27 +00:00
Simon Jakobi
5c0c1f4e77 dhall-lsp-server: Document the integration tests gotcha (#1506)
Context: https://github.com/dhall-lang/dhall-haskell/pull/1483#issuecomment-548954080
2019-11-02 04:00:32 +00:00
David Francoeur
1b46f1885f Attempt at fixing missing root certificate, #1491 (#1493)
* Attempt at fixing missing root certificate, #1491

https://github.com/dhall-lang/dhall-haskell/issues/1491

* Remove extra comma in shared.nix

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

* Update nix/shared.nix

Co-Authored-By: Gabriel Gonzalez <Gabriel439@gmail.com>
2019-11-02 03:25:57 +00:00
Simon Jakobi
976f70752d dhall-lsp-server: Fix doctests (#1505) 2019-11-02 01:29:26 +00:00
Gabriel Gonzalez
7ea5f6fa51 Remove support for fusion (#1478)
* Remove support for fusion

... as standardized in https://github.com/dhall-lang/dhall-lang/pull/792

* Update `dhall.cabal` to match the latest Prelude

* Update `dhall-lang`

... and blacklist tests we don't support yet

* Add missing files to `dhall.cabal`
2019-11-01 05:33:05 +00:00
Gabriel Gonzalez
b843cae5d2
Improve encoding/decoding speed (#1500)
... by not going through a `Term` intermediate

This gives a ~28% performance in decoding improvement, which means that
cache looks are not faster.

Here are the new decoding benchmarks before and after this change:

Before:

```
benchmarked Issue #108/Binary
time                 266.5 μs   (265.7 μs .. 267.4 μs)
                     1.000 R²   (1.000 R² .. 1.000 R²)
mean                 266.3 μs   (265.6 μs .. 267.1 μs)
std dev              2.418 μs   (1.891 μs .. 3.436 μs)

benchmarking Kubernetes/Binary ... took 36.94 s, total 56 iterations
benchmarked Kubernetes/Binary
time                 641.3 ms   (623.0 ms .. 655.4 ms)
                     0.999 R²   (0.997 R² .. 1.000 R²)
mean                 679.7 ms   (665.5 ms .. 702.6 ms)
std dev              29.48 ms   (14.15 ms .. 39.05 ms)
```

After:

```
benchmarked Issue #108/Binary
time                 282.2 μs   (279.6 μs .. 284.7 μs)
                     1.000 R²   (0.999 R² .. 1.000 R²)
mean                 281.9 μs   (280.7 μs .. 287.7 μs)
std dev              7.089 μs   (2.550 μs .. 15.44 μs)
variance introduced by outliers: 11% (moderately inflated)

benchmarking Kubernetes/Binary ... took 27.57 s, total 56 iterations
benchmarked Kubernetes/Binary
time                 499.1 ms   (488.1 ms .. 506.6 ms)
                     0.999 R²   (0.998 R² .. 1.000 R²)
mean                 498.9 ms   (494.4 ms .. 503.9 ms)
std dev              8.539 ms   (6.236 ms .. 12.56 ms)
```

There's a slight performance regression for the decoding microbenchmark, but
in practice my testing on real examples matches performance improvements seen
in the larger benchmark based on an example cache product from
`dhall-kubernetes`.

Note that is a breaking change because:

* There is no longer a `FromTerm` nor `ToTerm` class.  Now we use the
  `Serialise` class and `{encode,decode}Expression` now work on `ByteString`s
  instead of `Term`s

* I further narrowed the types of several encoding/decoding utilites to expect a
  `Void` for the first type parameter of `Expr`

* This is a regression with respect to stripping 55799 CBOR tags, mainly
  because properly handling the tags at every possible point in the syntax tree
  would considerably complicate the code
2019-10-31 20:05:22 -07:00
Simon Jakobi
5ceb8d9d60 dhall-lsp-server: Fix lower bound on dhall (#1495)
* dhall-lsp-server: Fix lower bound on dhall

… as reported in https://github.com/dhall-lang/dhall-haskell/issues/1494.

* Require base >= 4.11

Previously there were build failures with GHC-8.2 and 8.0 due to `(<>)` being out of scope.
2019-10-30 19:23:29 +00:00
Simon Jakobi
9d16602388
Follow-up fixes for #1485 (#1489) 2019-10-30 16:13:51 +01:00
Simon Jakobi
d5b7c3860e
Rename Type to Decoder, InputType to Encoder (#1485)
* s/InputType/Encoder

* Rename input* functions on the ToDhall side to encode*

* Haddocks: Use "encoder" instead of "injector"

* s/Type/Decoder

* Haddocks: Stop using the word "parser" for Decoders

* Rename encode{Record,Union} to {record,union}Encoder
2019-10-30 14:24:15 +01:00
Simon Jakobi
343e64e0ce Update reservedIdentifiers (#1473)
* Add `missing` and `assert`
* Reformat them to match the grammar
2019-10-30 12:31:30 +00:00
Aleksei Pirogov
2a8735c202 Make some of CLI options for dhall-json more consistent (#1475)
* Make some of CLI options for dhall-json more consistent

* fix option parser and array nullification

* update changelog
2019-10-29 19:05:13 +00:00
Gabriel Gonzalez
1349a50f91 Add Integer/{clamp,negate} built-ins (#1486)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/780
2019-10-29 17:21:00 +00:00
Simon Jakobi
8e52b9da45 AppVeyor: Allow branch builds for branches containing "appveyor-build-branch" (#1484)
… as discussed in https://github.com/dhall-lang/dhall-haskell/pull/1479.
2019-10-28 18:26:29 +00:00
Gabriel Gonzalez
1a0778e9fa Don't include context in default output (#1482)
The motivation for this is so that `dhall` can be made much faster on very
large projects like `dhall-kubernetes-charts` where vast majority of the time
is spent rendering the very large `Context` when type-checking fails, delaying
the user from getting to the actual error message.

The `Context` also gets in the way of the user noticing the (far more useful)
type diff, but the performance cost is the primary motivation for this change.

If the user wants the context they can still use the `--explain` flag.
2019-10-27 23:52:50 +00:00
Gabriel Gonzalez
5c26dace8b Improve parsing error messages (#1443)
* Improve parsing error messages

The main changes are:

* Don't quote expected tokens in the error message (to avoid visual clutter)
* Consolidate expected tokens into simpler categories (e.g. "operator" or
  "literal") instead of listing them all

For example, this would be an error message before this change:

```
$ dhall <<< '1 + [1'
dhall:
Error: Invalid input

(stdin):2:1:
  |
2 | <empty line>
  | ^
unexpected end of input
expecting "!=", "&&", "++", "->", "//", "//\\", "/\", "==", "===", "merge", "toMap", "||", "→", "∧", "≡", "⩓", "⫽", '#', '(', '*', '+', ',', '.', ':', '?', ']', built-in expression, double infinity, double literal, import, integer literal, label, list literal, natural literal, record type or literal, text literal, union type, or whitespace
```

... and this would be an error message after this change:

```
$ dhall <<< '1 + [1'
dhall:
Error: Invalid input

(stdin):1:4:
  |
1 | 1 + [1
  |    ^^^^
unexpected " [1<newline>"
expecting (, import, keyword, label, or literal
```

* Fix test failures

* Fix warnings
2019-10-27 03:34:33 +00:00
Simon Jakobi
458c873706 Website: List XML integration via dhall-xml-ruby (#1481) 2019-10-27 01:55:01 +00:00
Simon Jakobi
149e80346b
AppVeyor: Install stack without using Chocolatey (#1479)
Also don't build branches that have "appveyor" in their name.
That seemed just redundant to me.
2019-10-26 22:24:54 +02:00
Gabriel Gonzalez
90415e12d1 Update release script (#1477)
This is automating slightly more of the release process that I perform
2019-10-26 16:23:50 +00:00
Gabriel Gonzalez
d08ccfb384
Update website to use dhall-json for generating YAML (#1476)
Now that we depend on a pure Haskell implementation of YAML we can
use the `dhall-json` package for rendering YAML with GHCJS
2019-10-25 20:39:21 -07:00
Gabriel Gonzalez
8e7586b247
Fix dhall-to-yaml to quote special strings (#1474)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1472

This also refactors the code to a form that was easier for me to understand
2019-10-25 08:29:32 -07:00
Gabriel Gonzalez
90315e9eda Fix dhall freeze to always re-freeze an import (#1471)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/1470

`dhall freeze` no longer attempts to use the cache to fetch an import since
the cache might not match the underlying import any longer.  Instead,
`dhall freeze` now always attempts to fetch the underlying import to
compute the new hash.
2019-10-24 15:19:09 +00:00
Simon Jakobi
8f2c28a5dc
Move normalization code from Dhall.Core to a new module Dhall.Normalize (#1452)
Also try to decouple a few modules from Dhall.Core.

Closes #1127.
2019-10-24 00:01:02 +02:00
Simon Jakobi
6c2db48d42 Fix operator precedence in the parser (#1466)
Previously some operator expressions were associated incorrectly, e.g.

* a || b + c  -> (a || b) + c
* a // b == c -> (a // b) == c

Fixes #1457.
2019-10-23 19:50:17 +00:00
Michael Gilliland
16e6a12c3d Resolve #1451: fix format --check given STDIN input. (#1462)
* Resolve #1451: fix `format --check` given STDIN input.

I'm not really sure if this is the "best" approach so let me know if you
know a way to simplify this.

The issue was that `getExpressionAndHeader` was doing a second
`IO.getContents` (thus reading STDIN twice).

* Rename `Input` constructor.
2019-10-23 14:51:06 +00:00
Simon Jakobi
0f3a89eae6
Tweak the Header generator a bit (#1463)
* Reduce the discard rate by generating shorter Headers
   with more characters from the valid-ASCII range
* Shrink headers too
2019-10-23 05:06:24 +02:00
Basile Henry
3c99d5c988 Fix precedence of the import alt operator (#1460)
* Add test for format precedence #1455

* Fix precedence of the import alt operator
2019-10-23 01:19:50 +00:00
Simon Jakobi
62fd7a1b0d
Clarify the types involved in the formatting idempotence test (#1456)
Previously it wasn't obvious what the type parameters for the
'Expr' are.
2019-10-22 23:48:08 +02:00
Simon Jakobi
a3d9d2c9d2 Make the number of test cases for the idempotence test configurable on the CLI (#1453) 2019-10-22 20:38:55 +00:00
Basile Henry
69b228454e Test that dhall format is idempotent (#1427) 2019-10-22 19:45:08 +02:00