The abstract data type Doc ann represents pretty documents that have
been annotated with data of type ann.
More specifically, a value of type Doc represents a non-empty set of
possible layouts of a document. The layout functions select one of these
possibilities, taking into account things like the width of the output
document.
The annotation is an arbitrary piece of data associated with (part of) a document. Annotations may be used by the rendering backends in order to display output differently, such as
color information (e.g. when rendering to the terminal)
mouseover text (e.g. when rendering to rich HTML)
whether to show something or not (to allow simple or detailed versions)
The simplest way to display a Doc is via the Show class.
putStrLn (show (vsep ["hello", "world"]))helloworld
Constructors
FailOccurs when flattening a line. The layouter will reject this document, choosing a more suitable rendering.
EmptyThe empty document; conceptually the unit of Cat
Char !Charinvariant: not 'n'
Text !Int !TextLineHard line break
FlatAlt (Doc ann) (Doc ann)Cat (Doc ann) (Doc ann)Concatenation of two documents
Nest !Int (Doc ann)Document indented by a number of columns
Union (Doc ann) (Doc ann)Invariant: The first lines of first document should be longer than the first lines of the second one, so the layout algorithm can pick the one that fits best. Used to implement layout alternatives for group.
Column (Int -> Doc ann)React on the current cursor position, see column
WithPageWidth (PageWidth -> Doc ann)React on the document's width, see pageWidth
Nesting (Int -> Doc ann)React on the current nesting level, see nesting
Annotated ann (Doc ann)Add an annotation to the enclosed Doc. Can be used for example to add styling directives or alt texts that can then be used by the renderer.
Instances7Functor, Show, IsString, Generic, Semigroup, Monoid, …
Functor DocDefined in prettyprinter-1.7.1 · Prettyprinter.InternalAlter the document’s annotations.
This instance makes Doc more flexible (because it can be used in Functor-polymorphic values), but
fmapis much less readable compared to usingreAnnotatein code that only works forDocanyway. Consider using the latter when the type does not matter.Show (Doc ann)Defined in prettyprinter-1.7.1 · Prettyprinter.Internal(show doc)prettyprints documentdocwith defaultLayoutOptions, ignoring all annotations.IsString (Doc ann)Defined in prettyprinter-1.7.1 · Prettyprinter.InternalGeneric (Doc ann)Defined in prettyprinter-1.7.1 · Prettyprinter.InternalSemigroup (Doc ann)Defined in prettyprinter-1.7.1 · Prettyprinter.InternalMonoid (Doc ann)Defined in prettyprinter-1.7.1 · Prettyprinter.Internaltype Rep (Doc ann) = D1 ('MetaDataDefined in prettyprinter-1.7.1 · Prettyprinter.Internal"Doc"
"Prettyprinter.Internal"
"prettyprinter-1.7.1-HHxuhFuLsfvKGXtl3TXc21"
'False) (((C1 ('MetaCons"Fail"
'PrefixI 'False) U1 :+: (C1 ('MetaCons"Empty"
'PrefixI 'False) U1 :+: C1 ('MetaCons"Char"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Char)))) :+: (C1 ('MetaCons"Text"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Int) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Text)) :+: (C1 ('MetaCons"Line"
'PrefixI 'False) U1 :+: C1 ('MetaCons"FlatAlt"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ann)) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ann)))))) :+: ((C1 ('MetaCons"Cat"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ann)) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ann))) :+: (C1 ('MetaCons"Nest"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Int) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ann))) :+: C1 ('MetaCons"Union"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ann)) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ann))))) :+: ((C1 ('MetaCons"Column"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Int -> Doc ann))) :+: C1 ('MetaCons"WithPageWidth"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PageWidth -> Doc ann)))) :+: (C1 ('MetaCons"Nesting"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Int -> Doc ann))) :+: C1 ('MetaCons"Annotated"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ann) :*: S1 ('MetaSel 'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Doc ann)))))))