stringfmt
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Fmt.Functor

Description

Pattern functor for document trees.

Doc m ann is the base functor for pretty-printer documents, parametric over content type m and annotation type ann.

Changes from prettyprinter's DocF:

  • Char/Text merged into Leaf m (parametric content)
  • WithPageWidth dropped (recoverable via Column/Nesting)
  • Fail retained for lazy failure propagation through Column/Nesting
Synopsis

Pattern functor

data Doc m ann r Source #

One layer of a document tree.

r marks recursive positions. m is the content type (e.g. Text, Builder). ann is the annotation type (e.g. ANSI styles, HTML tags).

Constructors

Fail

Layout failure. Produced by flatten on hard line breaks; consumed by the layout algorithm to reject a flattened branch.

Empty

Empty document.

Leaf !Int !m

Literal content with cached display width.

Cat r r

Concatenation.

Line

Hard line break. Cannot be flattened (becomes Fail).

FlatAlt r r

FlatAlt default flat: use default normally, flat when flattened by group.

Nest !Int r

Nest i doc: increase nesting by i for doc.

Union r r

Union wide narrow: layout alternatives. Invariant: wide is the flattened form of narrow. Internal — constructed only by group.

Ann ann r

Annotated document.

Column (Int -> r)

React to the current column position.

Nesting (Int -> r)

React to the current nesting level.

Instances

Instances details
IsString m => IsString (Tree m ann) Source # 
Instance details

Defined in Data.Fmt.Functor

Methods

fromString :: String -> Tree m ann #

Functor (Doc m ann) Source # 
Instance details

Defined in Data.Fmt.Functor

Methods

fmap :: (a -> b) -> Doc m ann a -> Doc m ann b #

(<$) :: a -> Doc m ann b -> Doc m ann a #

Monoid (Tree m ann) Source # 
Instance details

Defined in Data.Fmt.Functor

Methods

mempty :: Tree m ann #

mappend :: Tree m ann -> Tree m ann -> Tree m ann #

mconcat :: [Tree m ann] -> Tree m ann #

Semigroup (Tree m ann) Source # 
Instance details

Defined in Data.Fmt.Functor

Methods

(<>) :: Tree m ann -> Tree m ann -> Tree m ann #

sconcat :: NonEmpty (Tree m ann) -> Tree m ann #

stimes :: Integral b => b -> Tree m ann -> Tree m ann #

Tree

type Tree m ann = Mu (Doc m ann) Source #

A document tree: the initial algebra of Doc m ann.