template-haskell-2.5.0.0

Language.Haskell.TH.PprLib

Contents

Description

Monadic front-end to Text.PrettyPrint.HughesPJ

Synopsis

The document type

data PprM a Source

Instances

Primitive Documents

empty :: DocSource

An empty document

semi :: DocSource

A ';' character

comma :: DocSource

A ',' character

colon :: DocSource

A : character

space :: DocSource

A space character

equals :: DocSource

A '=' character

lparen :: DocSource

A '(' character

rparen :: DocSource

A ')' character

lbrack :: DocSource

A '[' character

rbrack :: DocSource

A ']' character

lbrace :: DocSource

A '{' character

rbrace :: DocSource

A '}' character

Converting values into documents

Wrapping documents in delimiters

parens :: Doc -> DocSource

Wrap document in (...)

brackets :: Doc -> DocSource

Wrap document in [...]

braces :: Doc -> DocSource

Wrap document in {...}

quotes :: Doc -> DocSource

Wrap document in '...'

doubleQuotes :: Doc -> DocSource

Wrap document in "..."

Combining documents

(<>) :: Doc -> Doc -> DocSource

Beside

(<+>) :: Doc -> Doc -> DocSource

Beside, separated by space

hcat :: [Doc] -> DocSource

List version of <>

hsep :: [Doc] -> DocSource

List version of <+>

($$) :: Doc -> Doc -> DocSource

Above; if there is no overlap it "dovetails" the two

($+$) :: Doc -> Doc -> DocSource

Above, without dovetailing.

vcat :: [Doc] -> DocSource

List version of $$

sep :: [Doc] -> DocSource

Either hsep or vcat

cat :: [Doc] -> DocSource

Either hcat or vcat

fsep :: [Doc] -> DocSource

"Paragraph fill" version of sep

fcat :: [Doc] -> DocSource

"Paragraph fill" version of cat

nest :: Int -> Doc -> DocSource

Nested

hang :: Doc -> Int -> Doc -> DocSource

hang d1 n d2 = sep [d1, nest n d2]

punctuate :: Doc -> [Doc] -> [Doc]Source

punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn]

Predicates on documents

isEmpty :: Doc -> PprM BoolSource

Returns True if the document is empty