Annotation type used to tag elements in a pretty-printed document for syntax highlighting purposes
Moduledhall-1.42.3Haskell2010
Dhall.Pretty
This module contains logic for pretty-printing expressions, including support for syntax highlighting
- 3 types
- 10 values
- Packagedhall-1.42.3
- Exports13
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourcePretty.hs
Pretty
13 declarationsConvert annotations to their corresponding color for syntax highlighting purposes
Pretty print an expression
Instances11Eq, Data, Ord, Show, Generic, Semigroup, …
Eq CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalData CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalOrd CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalShow CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalGeneric CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalSemigroup CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalSince ASCII is a subset of Unicode, if either argument is Unicode, the result is Unicode
Monoid CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalNFData CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalFromJSON CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.InternalLift CharacterSetDefined in dhall-1.42.3 · Dhall.Pretty.Internaltype Rep CharacterSet = D1 ('MetaDataDefined in dhall-1.42.3 · Dhall.Pretty.Internal"CharacterSet"
"Dhall.Pretty.Internal"
"dhall-1.42.3-5OoAJpk2vIpARwiStLO8GU"
'False) (C1 ('MetaCons"ASCII"
'PrefixI 'False) U1 :+: C1 ('MetaCons"Unicode"
'PrefixI 'False) U1)
The character set used by default in functions throughout the Dhall code base.
Detect which character set is used for the syntax of an expression If any parts of the expression uses the Unicode syntax, the whole expression is deemed to be using the Unicode syntax.
Pretty-print an Expr using the given CharacterSet.
prettyCharacterSet largely ignores Notes. Notes do however matter for the layout of let-blocks:
let inner = Let (Binding Nothing "x" Nothing Nothing Nothing (NaturalLit 1)) (Var (V "x" 0)) :: Expr Src ()prettyCharacterSet ASCII (Let (Binding Nothing "y" Nothing Nothing Nothing (NaturalLit 2)) inner)let y = 2 let x = 1 in xprettyCharacterSet ASCII (Let (Binding Nothing "y" Nothing Nothing Nothing (NaturalLit 2)) (Note (Src unusedSourcePos unusedSourcePos "") inner))let y = 2 in let x = 1 in x
This means the structure of parsed let-blocks is preserved.
Layout using layoutOpts
Tries hard to fit the document into 80 columns.
This also removes trailing space characters (' ') unless
they are enclosed in an annotation.
Default layout options
Escape an environment variable if not a valid Bash environment variable
The set of labels which do not need to be escaped
Constructors
NonReservedLabelThis corresponds to the `nonreserved-label` rule in the grammar
AnyLabelThis corresponds to the `any-label` rule in the grammar
AnyLabelOrSomeThis corresponds to the `any-label-or-some` rule in the grammar
Escape a label if it is not valid when unquoted
Convert an expression representing a temporal value to Text, if possible
This is used by downstream integrations (e.g. `dhall-json` for treating temporal values as strings