Commit Graph

883 Commits

Author SHA1 Message Date
Gabriel Gonzalez
375688c97c
Small improvements to dhall format (#831)
Fixes #832 832

This includes two changes:

* Fix a missing newline at the end of `dhall format` output when not using
  the `--inplace` option

* Better align ASCII output
2019-02-27 11:32:48 -08:00
Gabriel Gonzalez
744a90c547
Add :set/:unset commands to dhall repl (#828)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/823

These allow one to enable or disable command-line options

Currently these only support `--explain`
2019-02-25 08:51:02 -08:00
Gabriel Gonzalez
45a6ceedaa
Explain how to use cache.dhall-lang.org (#827)
Related to #783
2019-02-24 12:43:43 -08:00
Fabrizio Ferrai
8527a651d7 CBOR-encode only some special values as half-floats (#822)
Co-Authored-By: f-f <fabrizio.ferrai@gmail.com>
2019-02-23 11:21:28 -08:00
Gabriel Gonzalez
7604a5870e
Mention submodule in instructions (#820)
This prevents build failures when running tests for the `dhall` package
2019-02-23 10:53:38 -08:00
Javier Neira
d714754e14 Show some details in InvalidType error output (#824) 2019-02-23 09:49:14 -08:00
Gabriel Gonzalez
5b0686b01c
Fix relative precedence of != and == (#825)
Fixes https://github.com/dhall-lang/dhall-lang/issues/373

The standard specifies that `!=` should have higher precedence than `==`,
which this change fixes.
2019-02-23 08:56:16 -08:00
Ollie Charles
abddcd6678 Correct Dhall installation one-liner in README (#826)
The README missed the call to `curl -L`.
2019-02-23 08:31:43 -08:00
Gabriel Gonzalez
8663bfe296
Add linux-dhall* jobs to Hydra (#821)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/783

These can be used to conveniently install Dhall using `nix-env` on Linux systems
2019-02-22 07:32:59 -08:00
Javier Neira
e8d4b78a3f Build dhall-json with lts-6 in appveyor (#818) 2019-02-15 15:09:35 -08:00
Gabriel Gonzalez
e3dde9dfa7
Implement Text/show (#811)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/365
2019-02-12 18:42:48 -08:00
Ollie Charles
7349eb08c3 Remove explicit recursion from Dhall lint in favour of micropasses (#817) 2019-02-12 17:18:23 -08:00
Gabriel Gonzalez
a3495fbe15
Add a standard-compatibility table (#816)
... as suggested by @jneira here:

https://github.com/dhall-lang/dhall-haskell/issues/791#issuecomment-457105469
2019-02-12 10:05:49 -08:00
Gabriel Gonzalez
112efa7df7
Fix import source locations (#815)
.. as caught by @Profpatsch in:

https://github.com/dhall-lang/dhall-haskell/pull/812#issuecomment-462134701

Before this change the location was always being reported as `(stdin):1:1`
because the `SourcedException` kept getting modified with a broader
source location in the `Note` branch of `loadWith`.

This was originally done so that alternative imports would show the entire
source span, but it mistakenly just kept bubbling up regardless of whether or
not there were alternative imports.

Instead, this includes an approximate source span for alternative imports.
The source span bounds are correct but the contents just show which imports
were alternated, even if they might have been buried in a larger expression.

For example, if the original expression had been:

```haskell
Some ./x ? None ./y
```

... then the source span for the error message would display just:

```haskell
./x ? ./y
```

... which is probably as good as it will get for now.
2019-02-12 09:04:32 -08:00
Gabriel Gonzalez
68c5278559
Support GHC 7.10.3 for all Dhall packages (#814)
This also updates the declared set of GHC versions tested with in the
`.cabal` files
2019-02-11 22:45:34 -08:00
Basile Henry
d20b1ca60d Save and load REPL context via :save and :load commands (#807)
The format for the save file is a plain Dhall file containing REPL commands.
This will hopefully mean that the save file can be edited manually if need be
without too much effort.

Signed-off-by: Basile Henry <bjm.henry@gmail.com>
2019-02-11 22:24:29 -08:00
Gabriel Gonzalez
98497e44ec
Add source position information for missing imports (#812)
Related to #561

This adds source position information to missing imports

Before:

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

↳ ./foo

Error: Missing file …/foo
```

After:

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

↳ ./foo

Error: Missing file …/foo

(stdin):1:1
```
2019-02-08 07:32:00 -08:00
Gabriel Gonzalez
2cdaf91636
Add --check flag to dhall format (#810)
Fixes #809

This allows the user to check if the input is formatted instead of formatting
the input
2019-02-06 18:19:25 -08:00
Gabriel Gonzalez
2f26dac1ff
Add support for Unicode path components (#800)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/353
2019-02-04 19:14:07 -08:00
Gabriel Gonzalez
04ec45803d
Remove version tag from encoded expressions (#805)
* Remove version tag from encoded expressions

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

This includes backwards compatibility for older encoded expressions
2019-02-03 21:17:41 -08:00
Gabriel Gonzalez
15d0b8d063
Change dhall freeze to only freeze Remote imports (#808)
The motivation behind this change is so that users can freeze remote imports
(like the Prelude) but ignore local imports so that subsequent runs of the
interpreter reflect changes to local files and environment variables.

The reasoning behind this is that there are two primary benefits of integrity
checks:

* Improved security
* Caching

... and one downside which is that updates to those imports are not pulled in
until the integrity check is updated or removed.

However, environment variables and local file paths do not benefit from
improved security or caching, so there is only a downside to freezing them.

Specifically:

* Environment variables and local file paths are both cheap to resolve

  ... so they don't really benefit from caching.

  To be precise, they *could* benefit from caching if the cache expression is
  cheaper to parse and normalize compared to the original file.  For those
  cases there is still an `--all` flag to freeze all imports.

* Environment variables and local file paths are trusted

  For example, when a user runs the `dhall` executable they are implicitly
  trusting their filesystem which provides that executable.  Similarly, when
  they run `dhall` without an absolute path they are implicitly trusting that
  their `PATH` environment variable has not been compromised to point to a
  malicious executable.

  Up until now, Dhall's threat model has always been that local imports are
  trusted but remote imports are not, so this is consistent with that threat
  model.

... so as far as environment variables and local files are concerned there are
only downsides to freezing them and no up-side.  This is why this change
no longer freezes them.

This also renames `hashImport` to `freezeImport` for more terminology
consistency.
2019-02-01 07:46:03 -08:00
Ville Tirronen
b2514ff8bf Add --immediate-dependencies flag to resolve mode (#803)
This is useful for integrating dhall to build systems where dhall
expressions (e.g. of type `Text`) are build products.

This also renames the `--list` flag to `--transitive-dependencies`
2019-01-31 15:24:17 -08:00
Gabriel Gonzalez
1a94f5558e
Fix parser for natural-raw (#804)
Fixes https://github.com/dhall-lang/dhall-lang/issues/357

This uses `Text.Megaparsec.Char.Lexer.decimal` which matches the Dhall
grammar.  The previous `decimal` parser was also accepting non-standard
hex and octal literals.
2019-01-31 13:05:19 -08:00
Basile Henry
29375ad462 Add :hash command to the repl (#806)
Signed-off-by: Basile Henry <bjm.henry@gmail.com>
2019-01-31 12:12:05 -08:00
Gabriel Gonzalez
54a9ebaab5
Build against ansi-terminal-0.9 (#802)
Related to https://github.com/commercialhaskell/stackage/issues/4329
2019-01-30 22:30:14 -08:00
Gabriel Gonzalez
bc4fc87043
Update to latest standard revision (#799) 2019-01-29 21:52:30 -08:00
Ville Tirronen
3fbd0d72f8 Add --list flag to dhall resolve (#795)
This commit adds a flag for producing a machine readable listing of
dependencies of a dhall expression.

This flag can be used to integrate dhall more easily to file watchers or
build systems which require such lists of dependencies.
2019-01-28 21:43:37 -08:00
Gabriel Gonzalez
2d2c897e3f
Include standard version in dhall version output (#793)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/791
2019-01-25 09:01:55 -08:00
Mario Lang
0460f28a38 Fix a typo (#792) 2019-01-23 14:57:06 -08:00
Javier Neira
a2a7985f5e Use appveyor to build, test and deploy in windows (#785) 2019-01-22 08:15:29 -08:00
Gabriel Gonzalez
095ee6db61
Don't fail if $HOME environment variable is unset (#789)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/788

This removes the dependency on the `directory` library's utility
functions (which require `HOME` to be set)
2019-01-21 08:22:16 -08:00
Gabriel Gonzalez
bebfbf2a5a
Change default.nix to use static linking when possible (#786)
Fixes https://github.com/dhall-lang/dhall-haskell/issues/783

... as suggested by @PierreR in https://github.com/dhall-lang/dhall-haskell/issues/783#issuecomment-455502506
2019-01-19 09:36:47 -08:00
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
Gabriel Gonzalez
f8e31956e9
Fix first example on dhall-lang.org (#762)
Several people commented that they had difficulty with the first example:

* They didn't realize that the mistake was supposed to be typo because they
  never found it
* They didn't realize they were supposed to progress to the next tab

This changes fixes those two issues
2018-12-21 08:52:42 -06:00
Gabriel Gonzalez
2635c582eb
Add contributing instructions for the website (#760)
This is so that I can link people to the `README` if they are interested in
improving the site
2018-12-20 10:36:10 -08:00