HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduleprettyprinter-1.7.2Haskell2010

Prettyprinter.Render.Util.SimpleDocTree

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

Contents
  1. Type and conversion
  2. Manipulating annotations
  3. Common use case shortcut definitions
Synopsis

Type and conversion

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

Common use case shortcut definitions

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<<<!