Community
Modules 28

Data.Text.Prettyprint.Doc.Render.Util.SimpleDocTree

Use \ Prettyprinter.Render.Util.SimpleDocTree\ instead.

module Prettyprinter.Render.Util.SimpleDocTree prettyprinter-1.7.2 · 7 declarations

alterAnnotationsST :: (ann -> [ann']) -> SimpleDocTree ann -> SimpleDocTree ann'

Change the annotation of a document to a different annotation, or none at all. alterAnnotations for SimpleDocTree.

Note that this is as powerful as alterAnnotations, allowing one annotation to become multiple ones, contrary to alterAnnotationsS, which cannot do this.

reAnnotateST :: (ann -> ann') -> SimpleDocTree ann -> SimpleDocTree ann'

Change the annotation of a document. reAnnotate for SimpleDocTree.

renderSimplyDecorated :: Monoid out => (Text -> out) -> (ann -> out -> out) -> SimpleDocTree ann -> out

Simplest possible tree-based renderer.

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

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

Render plain Text

(ann -> out -> out)

How to modify an element with an annotation

renderSimplyDecoratedA :: (Applicative f, Monoid out) => (Text -> f out) -> (ann -> f out -> f out) -> SimpleDocTree ann -> f out

Version of renderSimplyDecoratedA that allows for Applicative effects.

(Text -> f out)

Render plain Text

(ann -> f out -> f out)

How to modify an element with an annotation

treeForm :: SimpleDocStream ann -> SimpleDocTree ann

Convert a SimpleDocStream to its SimpleDocTree representation.

unAnnotateST :: SimpleDocTree ann -> SimpleDocTree xxx

Remove all annotations. unAnnotate for SimpleDocTree.

data 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.

STChar :: Char -> SimpleDocTree ann

STText :: Int -> Text -> SimpleDocTree ann

STLine :: Int -> SimpleDocTree ann

STAnn :: ann -> (SimpleDocTree ann) -> SimpleDocTree ann

STConcat :: [SimpleDocTree ann] -> SimpleDocTree ann

Build record and source files

Community contribution. The service has not verified this documentation. The generator reported 21 diagnostics.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-858b1951-web-1

Metadata snapshot: 19f659e0fd2a9606431ae6a3ec65f9ace725052e19ca6a9f9e9f2759e30fd129

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.