Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains the implementation of the dhall lint
command
Synopsis
- lint :: Expr s Import -> Expr s Import
- removeUnusedBindings :: Eq a => Expr s a -> Maybe (Expr s a)
- fixAssert :: Expr s a -> Maybe (Expr s a)
- fixParentPath :: Expr s Import -> Maybe (Expr s Import)
- removeLetInLet :: Expr s a -> Maybe (Expr s a)
- replaceOptionalBuildFold :: Expr s a -> Maybe (Expr s a)
- replaceSaturatedOptionalFold :: Expr s a -> Maybe (Expr s a)
- useToMap :: Expr s a -> Maybe (Expr s a)
Lint
lint :: Expr s Import -> Expr s Import Source #
Automatically improve a Dhall expression
Currently this:
- removes unused
let
bindings withremoveUnusedBindings
. - fixes
let a = x ≡ y
to belet a = assert : x ≡ y
- consolidates nested
let
bindings to use a multiple-let
binding withremoveLetInLet
- fixes paths of the form
./../foo
to../foo
- Replaces deprecated
Optional/fold
andOptional/build
built-ins
fixAssert :: Expr s a -> Maybe (Expr s a) Source #
Fix Let
bindings that the user probably meant to be assert
s
fixParentPath :: Expr s Import -> Maybe (Expr s Import) Source #
This transforms ./../foo
into ../foo
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
useToMap :: Expr s a -> Maybe (Expr s a) Source #
This replaces a record of key-value pairs with the equivalent use of
toMap
This is currently not used by dhall lint
because this would sort Map
keys, which is not necessarily a behavior-preserving change, but is still
made available as a convenient rewrite rule. For example,
{json,yaml}-to-dhall
use this rewrite to simplify their output.