v12.0.0
Breaking changes:
-
New
Integer/negate
andInteger/clamp
builtinsThis change adds two new built-ins so that
Integer
s are no longer opaque.
These two built-ins permit transforming back and forth betweenInteger
s and
Natural
numbers, so you can in theory now implement arbitrary operations on
Integer
s.These two built-ins have the following types:
-
Integer/clamp : Integer → Natural
- Converts anInteger
to aNatural
number, truncating to0
if theInteger
was negative -
Integer/negate : Integer → Integer
- Negates anInteger
See below for the matching change to the Prelude to use these built-ins to
power several new Prelude utilities. -
-
This removes support for
Natural
/List
/Optional
"fusion".For example, before this change an expression such as:
λ(x : Natural) → Natural/build (Natural/fold x)
... would simplify to:
λ(x : Natural) → x
... or in other words paired occurrences of
Natural/build
andNatural/fold
would "fuse" away and disappear since they are inverses of one another.
Similarly,List/build
/List/fold
andOptional/build
/Optional/fold
would
fuse away in the same way.After this change they no longer do so. We removed language support for
fusion for two reasons:-
Fusion was specified in such a way that the language was no longer
confluentNote: We have not proven that the language is now confluent in the absence
of fusion, but we are certain that fusion was interfering with confluence.A practical consequence of the absence confluence was that fusion-related
optimizations were brittle -
Fusion added implementation complexity
... which in turn increased the difficulty of porting new language bindings
This is a technically breaking change because the normal forms for certain
expressions will differ if they relied on fusion, which in turn would perturb
semantic integrity checks protecting those expressions. In practice, you are
unlikely to be affected by this change. -
New features:
-
Add new
Integer
functions to PreludeThis change takes advantage of the newly added
Integer/{clamp,negate}
built-ins to add the following operations onInteger
s to the Prelude:-
Integer.abs : Integer → Natural
-
Integer.add : Integer → Integer → Integer
-
Integer.clamp : Integer → Natural
-
Integer.equal : Integer → Integer → Bool
-
Integer.greaterThan : Integer → Integer → Bool
-
Integer.greaterThanEqual : Integer → Integer → Bool
-
Integer.lessThan : Integer → Integer → Bool
-
Integer.lessThanEqual : Integer → Integer → Bool
-
Integer.multiply : Integer → Integer → Integer
-
Integer.negate : Integer → Integer
-
Integer.subtract: Integer → Integer → Integer
-
Integer.toNatural : Integer → Optional Natural
-
-
You can now render
JSON
values as YAML documents using a new
Prelude.JSON.renderYAML
utilityNote that this utility is not intended to be as featureful as the
dhall-to-yaml
command-line tool, but can still prove to be useful for:- Rendering YAML documents in pure Dhall when appropriate to do so
- Rendering JSON values as YAML
Text
for use in conciseassert
expressions
-
Add a
Prelude.JSON.omitNullFields
While
renderYAML
doesn't aim to be as comprehensive asdhall-to-yaml
we
can still provide anomitNull
utility which behaves similarly to the
--omitNull
flag for the command-line tool. This function removes all
null
-valued record fields from aJSON
expression:JSON/omitNull : JSON → JSON
-
This change exploits the recently-added
Natural/subtract
built-in to
implement high-performance list truncation utilities of the following types:-
List/take : Natural → ∀(a : Type) → List a → List a
-
List/drop : Natural → ∀(a : Type) → List a → List a
-
-
Add
JSON.tag{Inline,Nested}
helpers for union encodingThese are convenience utilities to support the
dhall-to-{json,yaml}
executables which provide a mechanism for converting union literals to
tagged JSON records:-
JSON/tagInline : ∀(tagFieldName : Text) → ∀(a : Type) → ∀(contents : a) → { contents : a, field : Text, nesting : < Inline | Nested : Text > }
-
JSON/tagNested : ∀(contentsFieldName : Text) → ∀(tagFieldName : Text) → ∀(a : Type) → ∀(contents : a) → { contents : a, field : Text, nesting : < Inline | Nested : Text > }
-
Other changes:
-
Fixes and improvements to the standard:
-
Fixes and improvements to the Prelude:
-
Fixes and improvements to the standard test suite: