HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

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 declarations
datadata Ann
#

Annotation type used to tag elements in a pretty-printed document for syntax highlighting purposes

Constructors

  • Keyword

    Used for syntactic keywords

  • Syntax

    Syntax punctuation such as commas, parenthesis, and braces

  • Label

    Record labels

  • Literal

    Literals such as integers and strings

  • Builtin

    Builtin types and values

  • Operator

    Operators

Instances1Show
  • Show AnnDefined in dhall-1.42.3 · Dhall.Pretty.Internal
datadata CharacterSet
#

This type determines whether to render code as ASCII or Unicode

Instances11Eq, Data, Ord, Show, Generic, Semigroup, …

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:

Example3 expressions
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.

valuelayout :: Doc ann -> SimpleDocStream ann
#

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.

datadata UnescapedLabel
#

The set of labels which do not need to be escaped

Constructors

  • NonReservedLabel

    This corresponds to the `nonreserved-label` rule in the grammar

  • AnyLabel

    This corresponds to the `any-label` rule in the grammar

  • AnyLabelOrSome

    This corresponds to the `any-label-or-some` rule in the grammar

valuetemporalToText :: Pretty a => Expr s a -> Maybe Text
#

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