Commit Graph

90 Commits

Author SHA1 Message Date
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
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
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
7b414d9846
Version 1.26.1 → 1.27.0 (#1428) 2019-10-20 07:00:43 -07:00
Patrick Mylund Nielsen
5087e4d22a
Bump aeson-yaml, and add YAML regression test for 'y' (#1420) 2019-10-15 09:18:21 -04:00
Patrick Mylund Nielsen
c92c6bbc22
Eta: Remove YAML FFI code and disable dhall-nix build 2019-10-15 06:22:49 -04:00
Patrick Mylund Nielsen
96e694d7c6
'gpl' cabal flag to switch between HsYAML and aeson-yaml (#1417) 2019-10-15 03:12:12 -04:00
Gabriel Gonzalez
17fb0e3c46
100% haddock coverage (#1416)
This updates the `dhall` package to have 100% haddock coverage and
also updates CI to enforce this going forward.

This also includes a change to deprecate the `X` type synonym, which
I noticed along the way
2019-10-13 22:22:39 -07:00
Akshay Mankar
194654c10c Optionally allow missing lists in yaml/json-to-dhall (#1414)
[#1410]
2019-10-11 21:43:05 +00:00
Gabriel Gonzalez
4b8b8cd730
Add new record completion operator (#1375)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/767
2019-10-11 08:26:51 -07:00
Vijay Tadikamalla
cced515494 Migrate to the HsYAML package (#1248) 2019-10-05 14:52:19 -07:00
Simon Jakobi
6a8e7e12cc
Dhall.JSON: Update documentation of Nesting type (#1385) 2019-10-04 18:28:33 +02:00
mujx
045ed99ae5 Add the --preserveNull flag and omit null fields by default on dhall-to-yaml (#1365)
* Add the `--preserveNull` flag and omit null fields by default on `dhall-to-yaml`

fixes #1354

* Restore the `--omitNull` flag and apply `--preserveNull` to `dhall-to-json`

* Adjust examples that return null fields

* Mention the default behaviour regarding nulls

* Null -> null
2019-10-04 02:21:47 +00:00
Dima
cc71c65c17 Enable --pretty by default for dhall-to-json (#1373)
* Enable --pretty by default for dhall-to-json

* add Deprecation notice into dhall-to-json help

* update dhall-to-json output examples in src/Dhall/JSON.hs
2019-10-03 02:08:39 +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
Taylor Fausak
8c388c7994 Fix Haddock formatting in dhallFromJSON (#1316) 2019-09-14 13:35:38 -07: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
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
Gabriel Gonzalez
eee75242a4 Fix {json,yaml}-to-dhall marshaling into empty lists (#1284)
This is essentially the same fix as #1186, applied in more places
2019-09-06 23:00:00 +00:00
Gabriel Gonzalez
96921f03ab
Fix dhall format to preserve let comments (#1273)
Related to https://github.com/dhall-lang/dhall-haskell/issues/145

Note that this also refactors `Let` to use `Binding` in order
to avoid having to duplicate `Src`-related fields in two
places.
2019-09-04 23:41:44 -05:00
Simon Jakobi
72fd2ac983
Treat multi-lets as syntactic sugar (#1242)
Closes #1185.

This mostly reverts "Add support for multi-`let` (#675)" /
8a5bfaa3b9.

Also:

* Add fields for Src
  This is useful for to make 'Note's less noisy during debugging:

      first srcText expr
2019-08-31 18:31:24 +02:00
Simon Jakobi
93711aecf8 Throw error when union value is incompatible with Inline nesting (#1226) 2019-08-20 03:12:16 +00:00
Gabriel Gonzalez
268c79631d Fix yaml-to-dhall support for empty objects (#1186)
* Fix `yaml-to-dhall` support for empty objects

`yaml-to-dhall` was decoding an empty object into:

```dhall
[] : { mapKey : Text, mapValue : Text }
```

... instead of:

```dhall
[] : List { mapKey : Text, mapValue : Text }
```

... which this change fixes

* Add missing test files

* Hopefully fix test failure on Windows

I suspect that the test failure is due to the locale for the test suite
not being set to UTF8
2019-08-09 18:21:40 +00:00
Simon Jakobi
1d58840feb
dhall-json: Nesting: Support empty alternatives as contents (#1204)
Closes #1201.
2019-08-06 13:24:18 +02:00
Gabriel Gonzalez
d66d1db33f Fix --version flag handling for dhall-json package (#1199)
* Fix `--version` flag handling for `dhall-json` package

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

This changes version to be a separate constructor for options parsing,
in order to make invalid states unrepresentable and to fix issues like
the above one.

* Undo `allowImports` changed

This was a change I forgot to stash while working on the fix for the
`--version` flag

* Fix missing `Paths_dhall_json` in `dhall-json.cabal`
2019-08-06 06:28:46 +00:00
Gabriel Gonzalez
7f2f57f975
Add support for dependent types (#1164) 2019-08-03 21:38:01 -07:00
Simon Jakobi
1700fa72d8 Fix import logic with --file for dhall-to-{json,yaml} (#1191)
Fixes #1183.
2019-08-03 11:03:42 +00:00
Gabriel Gonzalez
3abef4e3f0 Enable --records-strict by default for {json,yaml}-to-dhall (#1181)
This adds a new `--records-loose` flag and changes the default behavior
to `--records-strict`

The rationale for this change is so that this default behavior helps
more when users are still experimenting with the appropriate type to
use to decode a large and messy YAML file.

For example, suppose a user is trying to translate the following YAML
to Dhall:

```yaml
foo: 1
bar: true
```

... and they start with a empty Dhall type which they plan to fix in
response to error messages.  They'd get a surprising success:

```bash
$ yaml-to-dhall '{}' < ./example.yaml
{=}
```

... because the old default behavior is to ignore extra fields in the
YAML.  However, if we're strict by default then users don't have to
apply the `--records-strict` flag to get feedback on what they need
to change.
2019-08-02 19:56:09 +00:00
Ollie Charles
1b683295fc Implement Natural/subtract (#1133)
* Implement Natural/truncatedSubtract

* Restore commented out code

* Add pretty printing for Natural/truncatedSubtract

* Flip the order of the arguments

* truncatedSubtract -> subtract

* Whitespace

* Whitespace

* Whitespace

* Whitespace

* Remove a try

* Fix Core.hs

* Add a case in Arbitrary (Expr s a)

* Fix Dhall.JSON

* lift2 -> lift0

* Update Dhall.Diff

* Add extra reduction rules

* Fix

* Update Core.hs

* Update dhall-lang submodule

* Updated dhall-lang

* Try rolling back the dhall-lang revision

* Correct isNormalized

* Add more isNormalized rules

* Update dhall-nix
2019-08-02 00:12:43 +00:00
Simon Jakobi
beb1e7ba6f
Remove old union literal syntax (#1176)
…as standardized in https://github.com/dhall-lang/dhall-lang/pull/573.

Fixes #1175.
2019-07-31 04:44:36 +02:00
Gabriel Gonzalez
d45f3ec46b
Version 1.24.0 → 1.25.0 (#1156) 2019-07-28 21:46:32 -07:00
Gabriel Gonzalez
354346be91 Pretty-print output of {json,yaml}-to-dhall (#1150)
This enables syntax highlighting and formatted output for these two
programs
2019-07-24 13:33:41 +00:00
Simon Jakobi
7dc7856d10 dhall-json: Allow empty alternative for Nesting.Inline (#1122)
Fixes #1092.
2019-07-19 16:19:19 +00:00
Gabriel Gonzalez
1a27cad137 Add --file option to dhall-json executables (#1107)
* Add `--file` option to `dhall-json` executables

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

* s/JSON/expression/

... as caught by @sjakobi

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

* s/expression/YAML expression/

... as caught by @sjakobi

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

* Change the program descriptions for `{json,yaml}-to-dhall`

... as suggested by @sjakobi
2019-07-18 19:08:47 +00:00
Gabriel Gonzalez
81ef514652 Move more dhall-json test logic into data files (#1108)
* Move more `dhall-json` test logic into data files

... as suggested @sjakobi in https://github.com/dhall-lang/dhall-haskell/pull/1094#pullrequestreview-261053408

* Fix CI failure

... as caught by @sjakobi

* Fix missing import of `(<>)`

... as noted by @sjakobi
2019-07-15 17:08:38 +00:00
Mario
8aa2ac3ce9 Implementation of toMap (#1041)
... as standardized in https://github.com/dhall-lang/dhall-lang/pull/610
2019-07-15 08:28:29 -07:00
Simon Jakobi
b2cbc8227f Remove usage of legacy Optional syntax (#1091)
* Remove usage of legacy Optional syntax

* Dhall.JSON: Use multilet in examples

* Update dhall-json/src/Dhall/JSON.hs

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

* Update dhall-json/src/Dhall/JSON.hs

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

* Update dhall-json/src/Dhall/JSON.hs

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

* Update dhall-nix/src/Dhall/Nix.hs

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

* Update dhall-nix/src/Dhall/Nix.hs

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

* Revert changes to travis.yml

* Lint travis.dhall
2019-07-14 18:36:41 +00:00
Gabriel Gonzalez
e49710166e
Add dhall-json support for unions as keys (#1094)
This is inspired by this StackOverflow question:

https://stackoverflow.com/questions/56967374/dynamic-records-key-type
2019-07-12 22:25:46 -07:00
Gabriel Gonzalez
aff138e192 Handle empty alternatives when converting from JSON (#1083)
* Handle empty alternatives when converting from JSON

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

`dhall-to-{json,yaml}` treat empty alternatives as strings of the
same name, but `{json,yaml}-to-dhall` were missing the corresponding
logic to decode strings to empty alternatives, which this change
fixes.

This also ensures that the conversion logic contains no more
`undefined`s, by making the union conversion branch total.

* Clarify successful cases for union handling

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

* Add missing trailing newline

... as caught by @sjakobi
2019-07-08 03:09:24 +00:00
Gabriel Gonzalez
462f82a0f8 Build against optparse-applicative-0.15 (#1081)
Related to https://github.com/commercialhaskell/stackage/issues/4693
2019-07-07 11:49:11 +00:00
Gabriel Gonzalez
b8e19d614a Fix dhall-json's support for preserving alternative names (#1080)
* Fix `dhall-json`'s support for preserving alternative names

... as caught by @sjakobi in the course of #1077

The code has to be updated to reflect the new normal forms for
union literals

* Add tests

... as suggested by @sjakobi
2019-07-07 10:27:54 +00:00
Simon Jakobi
76efe630b2 Remove cruft related to the removed 'constructors' keyword (#1077) 2019-07-06 22:38:02 +00:00
Gabriel Gonzalez
92bdd56a34
Switch Var to use an Int (#1044)
Related to: https://github.com/dhall-lang/dhall-haskell/issues/1039

We'll probably never see indices that exceed the space of an `Int` and
the interpreter would probably not be able to handle 9223372036854775807
nested binders anyway.
2019-07-01 17:24:13 -07:00
Simon Jakobi
157c36b8a1 dhall-json: Use Dhall.Optics instead of lens (#1042)
This removes the following packages from `dhall-json`'s dependencies:

- adjunctions
- call-stack
- free
- invariant
- kan-extensions
- lens
- parallel
- reflection
- transformers-base
- void

* Fix bound on dhall
2019-06-29 14:58:17 -07:00