Skip to content

v12.0.0

Compare
Choose a tag to compare
@Gabriella439 Gabriella439 released this 30 Nov 18:08
· 300 commits to master since this release
9f24813

Breaking changes:

  • New Integer/negate and Integer/clamp builtins

    This change adds two new built-ins so that Integers are no longer opaque.
    These two built-ins permit transforming back and forth between Integers and
    Natural numbers, so you can in theory now implement arbitrary operations on
    Integers.

    These two built-ins have the following types:

    • Integer/clamp : Integer → Natural - Converts an Integer to a Natural
      number, truncating to 0 if the Integer was negative

    • Integer/negate : Integer → Integer - Negates an Integer

    See below for the matching change to the Prelude to use these built-ins to
    power several new Prelude utilities.

  • Remove support for fusion

    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 and Natural/fold
    would "fuse" away and disappear since they are inverses of one another.
    Similarly, List/build/List/fold and Optional/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
      confluent

      Note: 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 Prelude

    This change takes advantage of the newly added Integer/{clamp,negate}
    built-ins to add the following operations on Integers 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

  • Implement renderYAML

    You can now render JSON values as YAML documents using a new
    Prelude.JSON.renderYAML utility

    Note 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 concise assert expressions
  • Add a Prelude.JSON.omitNullFields

    While renderYAML doesn't aim to be as comprehensive as dhall-to-yaml we
    can still provide an omitNull utility which behaves similarly to the
    --omitNull flag for the command-line tool. This function removes all
    null-valued record fields from a JSON expression:

    • JSON/omitNull : JSON → JSON
  • Add List/{take,drop}

    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 encoding

    These 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: