dhall-1.30.0: A configuration language guaranteed to terminate

Safe HaskellNone




This module contains the implementation of the dhall lint command



lint :: Expr s Import -> Expr s Import Source #

Automatically improve a Dhall expression

Currently this:

  • removes unused let bindings with removeUnusedBindings.
  • fixes let a = x ≡ y to be let a = assert : x ≡ y
  • consolidates nested let bindings to use a multiple-let binding with removeLetInLet
  • fixes paths of the form ./../foo to ../foo
  • Replaces deprecated Optional/fold and Optional/build built-ins

removeUnusedBindings :: Eq a => Expr s a -> Maybe (Expr s a) Source #

Remove unused Let bindings.

fixAssert :: Expr s a -> Maybe (Expr s a) Source #

Fix Let bindings that the user probably meant to be asserts

fixParentPath :: Expr s Import -> Maybe (Expr s Import) Source #

This transforms ./../foo into ../foo

removeLetInLet :: Expr s a -> Maybe (Expr s a) Source #

The difference between

let x = 1 let y = 2 in x + y


let x = 1 in let y = 2 in x + y

is that in the second expression, the inner Let is wrapped by a Note.

We remove such a Note in order to consolidate nested let-blocks into a single one.

replaceOptionalBuildFold :: Expr s a -> Maybe (Expr s a) Source #

This replaces Optional/fold and Optional/build, both of which can be implemented within the language

replaceSaturatedOptionalFold :: Expr s a -> Maybe (Expr s a) Source #

This replaces a saturated Optional/fold with the equivalent merge expression