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
This commit is contained in:
parent
e04f5af952
commit
cc71c65c17
|
@ -1,3 +1,7 @@
|
||||||
|
Next version
|
||||||
|
|
||||||
|
* [BREAKING CHANGE: Enable `--pretty` by default for `dhall-to-json`](https://github.com/dhall-lang/dhall-haskell/issues/716)
|
||||||
|
|
||||||
1.4.1
|
1.4.1
|
||||||
|
|
||||||
* [Enable `--records-strict` by default for `{json-yaml}-to-dhall`](https://github.com/dhall-lang/dhall-haskell/pull/1181)
|
* [Enable `--records-strict` by default for `{json-yaml}-to-dhall`](https://github.com/dhall-lang/dhall-haskell/pull/1181)
|
||||||
|
|
|
@ -62,7 +62,7 @@ parseOptions =
|
||||||
Options.flag'
|
Options.flag'
|
||||||
True
|
True
|
||||||
( Options.long "pretty"
|
( Options.long "pretty"
|
||||||
<> Options.help "Pretty print generated JSON"
|
<> Options.help "Deprecated, will be removed soon. Pretty print generated JSON"
|
||||||
)
|
)
|
||||||
|
|
||||||
compactFlag =
|
compactFlag =
|
||||||
|
@ -73,7 +73,7 @@ parseOptions =
|
||||||
)
|
)
|
||||||
|
|
||||||
defaultBehavior =
|
defaultBehavior =
|
||||||
pure False
|
pure True
|
||||||
|
|
||||||
parseVersion =
|
parseVersion =
|
||||||
Options.flag'
|
Options.flag'
|
||||||
|
|
|
@ -56,7 +56,11 @@
|
||||||
Dhall @List@s translate to JSON lists:
|
Dhall @List@s translate to JSON lists:
|
||||||
|
|
||||||
> $ dhall-to-json <<< '[1, 2, 3] : List Natural'
|
> $ dhall-to-json <<< '[1, 2, 3] : List Natural'
|
||||||
> [1,2,3]
|
> [
|
||||||
|
> 1,
|
||||||
|
> 2,
|
||||||
|
> 3
|
||||||
|
> ]
|
||||||
|
|
||||||
Dhall @Optional@ values translate to @null@ if absent and the unwrapped
|
Dhall @Optional@ values translate to @null@ if absent and the unwrapped
|
||||||
value otherwise:
|
value otherwise:
|
||||||
|
@ -69,7 +73,10 @@
|
||||||
Dhall records translate to JSON records:
|
Dhall records translate to JSON records:
|
||||||
|
|
||||||
> $ dhall-to-json <<< '{ foo = 1, bar = True }'
|
> $ dhall-to-json <<< '{ foo = 1, bar = True }'
|
||||||
> {"foo":1,"bar":true}
|
> {
|
||||||
|
> "bar": true,
|
||||||
|
> "foo": 1
|
||||||
|
> }
|
||||||
|
|
||||||
Dhall unions translate to the wrapped value:
|
Dhall unions translate to the wrapped value:
|
||||||
|
|
||||||
|
@ -85,7 +92,22 @@
|
||||||
> , MyType.Person { age = 35, name = "Alice" }
|
> , MyType.Person { age = 35, name = "Alice" }
|
||||||
> ]
|
> ]
|
||||||
> $ dhall-to-json <<< "./config"
|
> $ dhall-to-json <<< "./config"
|
||||||
> [{"age":47,"name":"John"},{"location":"North Pole"},{"location":"Sahara Desert"},{"age":35,"name":"Alice"}]
|
> [
|
||||||
|
> {
|
||||||
|
> "age": 47,
|
||||||
|
> "name": "John"
|
||||||
|
> },
|
||||||
|
> {
|
||||||
|
> "location": "North Pole"
|
||||||
|
> },
|
||||||
|
> {
|
||||||
|
> "location": "Sahara Desert"
|
||||||
|
> },
|
||||||
|
> {
|
||||||
|
> "age": 35,
|
||||||
|
> "name": "Alice"
|
||||||
|
> }
|
||||||
|
> ]
|
||||||
|
|
||||||
You can preserve the name of the alternative if you wrap the value in a
|
You can preserve the name of the alternative if you wrap the value in a
|
||||||
record with three fields:
|
record with three fields:
|
||||||
|
@ -154,7 +176,13 @@
|
||||||
> ]
|
> ]
|
||||||
|
|
||||||
> $ dhall-to-json <<< './example.dhall'
|
> $ dhall-to-json <<< './example.dhall'
|
||||||
> {"foo":null,"bar":[1,true]}
|
> {
|
||||||
|
> "bar": [
|
||||||
|
> 1,
|
||||||
|
> true
|
||||||
|
> ],
|
||||||
|
> "foo": null
|
||||||
|
> }
|
||||||
|
|
||||||
Also, all Dhall expressions are normalized before translation to JSON:
|
Also, all Dhall expressions are normalized before translation to JSON:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user