v10.0.0
Breaking changes:
-
Remove old-style union literals from the language
This is the final phase of removing support for the old union literal syntax
and they are no longer supported.Now, instead of writing this:
< Left = 1 | Right : Bool >
... you must write this:
< Left : Natural | Right : Bool >.Left 1
... or more commonly:
let Example = < Left : Natural | Right : Bool > in Example.Left 1
For more details, including migration instructions, see: Migration: Deprecation of old union literal syntax
-
Add support for dependent types
Dhall now provides rudimentary support for dependent types, which in turn
enables a newassert
keyword for testing code.For example, now you can write unit tests for your functions like this:
let not = λ(x : Bool) → x == False let example0 = assert : not True === False -- (≡) (U+2261) is the Unicode analog of (===) let example1 = assert : not False ≡ True in not
You can also write property tests in the same way, too:
let rightIdentity = λ(x : Natural) → assert : x ≡ (x + 0) let leftIdentity = λ(x : Natural) → assert : x ≡ (0 + x) -- Note: This last assertion will fail because Dhall's simplifier currently -- cannot detect that re-associated expressions are equivalent let associativity = λ(x : Natural) → λ(y : Natural) → λ(z : Natural) → assert : (x + (y + z)) === ((x + y) + z) in {=}
Dhall is technically dependently typed, meaning that you can now have
functions from terms to types, like this:let Tagged = λ(label : Text) → λ(a : Type) → a in 1 : Tagged "Age" Natural
... but Dhall does not yet support other features that would be required to
do more sophisticated things like statically sizedVector
s. The main
new benefit for users is language support for tests.This is a technically breaking change because
assert
is now a reserved
keyword. -
This adds a new
Natural/subtract
built-in which truncates to0
if the
result is negative.The built-in is useful in its own right, but can also be used to power
other utilities (such as efficient comparison ofNatural
numbers, also
included in this releases)This is a technically breaking change because
Natural/subtract
is now a
reserved identifier, but in practice this is unlikely to break your code
unless you defined your own inefficientNatural/subtract
function in terms
ofNatural/fold
. If you did so, then just delete the old code and switch
to the new built-in.See also: Simplify
Natural/subtract
when its arguments are equivalent -
New simplifications for field selection
The interpreter will now intelligently normalize some unsaturated field
selections and projections.For example, the following code:
λ(x : { a : Bool, b : Bool }) → (x ⫽ { c = 0 }).{ a, c }.c
... will simplify to:
λ(x : { a : Bool, b : Bool }) → 0
This is a technically breaking change because it changes the normal form for
expressions that can be simplified in this way, which in turn perturbs
their hash if they are protected by a semantic integrity check. However, in
practice this is unlikely to disrupt your code.See also: Add missing symmetric rules for field selection normalization
-
Simplify
//
when its arguments are equivalentThe interpreter will now simplify
x // x
tox
This is a technically breaking change for the same reason as the previous
change: because it changes the normal form for expressions using this
feature. -
Don't URL-decode path segments
This changes the the binary representation of URLs to pass through path
segments without decoding them for better interoperability with other tools.This is a technically breaking change because the binary format changes for
URLs, but this does not disturb semantic integrity checks since they hash
URL-free expressions.
New features:
-
You can now have mixed records of terms, types, and kinds. For example,
something like this is now legal:{ foo = 1, bar = Text }
Practically, this means that Dhall packages can now export both types and
terms from the same record, so that they no longer need a separate
types.dhall
record. -
Prelude: Add
Natural
comparison functionsYou can now use high-performance
Natural
comparison functions which are
internally powered by the newly-addedNatural/subtract
built-in.
Other changes:
-
Fixes and improvements to the standard:
- Fix
toMap
type inference (and somemerge
tweaks) - [
Natural/subtract
] minor clarification in normalization - β-normalization: Simplify some equivalence-based rules
- Fix RFC5234-compliance of the grammar
- Small tweak for auto-generated parsers
- Small fix for β-normalization
- Use
⩓
to typecheck∧
- Clarify that dependent functions are allowed now
- Fix
-
Fixes and improvements to the Prelude:
-
Fixes and improvements to the standard test suite:
- Test import alternative with type error
- Test binary decoding of label 28
- Make
as Location
tests chain in a consistent way - Test binary decoding of label 27
- Test that nested lets are flattened in binary
- Test integrity check on nested imports
- Add normalization test for (
Natural/subtract 0
) - Add a bunch of tests
- Swap A and B in
BuiltinNaturalSubtract
binary-decode tests - Make normalization tests type-correct
- Fix
tests/typecheck/success/prelude
- Various test fixes