HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Moduleprettyprinter-1.7.2Haskell2010

Prettyprinter.Render.Util.SimpleDocTree

Conversion of the linked-list-like SimpleDocStream to a tree-like SimpleDocTree.

  • 1 type
  • 6 values

Type and conversion

2 declarations
datadata SimpleDocTree ann
#

A SimpleDocStream is a linked list of different annotated cons cells (SText and then some further SimpleDocStream, SLine and then some further SimpleDocStream, …). This format is very suitable as a target for a layout engine, but not very useful for rendering to a structured format such as HTML, where we don’t want to do a lookahead until the end of some markup. These formats benefit from a tree-like structure that explicitly marks its contents as annotated. SimpleDocTree is that format.

Constructors

Instances8Functor, Foldable, Traversable, Eq, Ord, Show, …

Manipulating annotations

3 declarations

Common use case shortcut definitions

2 declarations
valuerenderSimplyDecorated
  1. :: Monoid out
  2. => (Text -> out)

    Render plain Text

  3. -> (ann -> out -> out)

    How to modify an element with an annotation

  4. -> SimpleDocTree ann
  5. -> out
#

Simplest possible tree-based renderer.

For example, here is a document annotated with (), and the behaviour is to surround annotated regions with »>>>« and »<<<«:

Example3 expressions
let doc = "hello" <+> annotate () "world" <> "!"let stdoc = treeForm (layoutPretty defaultLayoutOptions doc)T.putStrLn (renderSimplyDecorated id (\() x -> ">>>" <> x <> "<<<") stdoc)hello >>>world<<<!