template-haskell-2.17.0.0: Support library for Template Haskell
Safe HaskellSafe
LanguageHaskell2010

Language.Haskell.TH.PprLib

Description

Monadic front-end to Text.PrettyPrint

Synopsis

The document type

data PprM a Source #

Instances

Instances details
Applicative PprM Source # 
Instance details

Defined in Language.Haskell.TH.PprLib

Methods

pure :: a -> PprM a Source #

(<*>) :: PprM (a -> b) -> PprM a -> PprM b Source #

liftA2 :: (a -> b -> c) -> PprM a -> PprM b -> PprM c Source #

(*>) :: PprM a -> PprM b -> PprM b Source #

(<*) :: PprM a -> PprM b -> PprM a Source #

Functor PprM Source # 
Instance details

Defined in Language.Haskell.TH.PprLib

Methods

fmap :: (a -> b) -> PprM a -> PprM b Source #

(<$) :: a -> PprM b -> PprM a Source #

Monad PprM Source # 
Instance details

Defined in Language.Haskell.TH.PprLib

Methods

(>>=) :: PprM a -> (a -> PprM b) -> PprM b Source #

(>>) :: PprM a -> PprM b -> PprM b Source #

return :: a -> PprM a Source #

Show Doc Source # 
Instance details

Defined in Language.Haskell.TH.PprLib

Primitive Documents

empty Source #

Arguments

:: Doc

An empty document

semi Source #

Arguments

:: Doc

A ';' character

comma Source #

Arguments

:: Doc

A ',' character

colon Source #

Arguments

:: Doc

A : character

dcolon Source #

Arguments

:: Doc

A "::" string

space Source #

Arguments

:: Doc

A space character

equals Source #

Arguments

:: Doc

A '=' character

arrow Source #

Arguments

:: Doc

A "->" string

lparen Source #

Arguments

:: Doc

A '(' character

rparen Source #

Arguments

:: Doc

A ')' character

lbrack Source #

Arguments

:: Doc

A '[' character

rbrack Source #

Arguments

:: Doc

A ']' character

lbrace Source #

Arguments

:: Doc

A '{' character

rbrace Source #

Arguments

:: Doc

A '}' character

Converting values into documents

Wrapping documents in delimiters

parens Source #

Arguments

:: Doc 
-> Doc

Wrap document in (...)

brackets Source #

Arguments

:: Doc 
-> Doc

Wrap document in [...]

braces Source #

Arguments

:: Doc 
-> Doc

Wrap document in {...}

quotes Source #

Arguments

:: Doc 
-> Doc

Wrap document in '...'

doubleQuotes Source #

Arguments

:: Doc 
-> Doc

Wrap document in "..."

Combining documents

(<>) infixl 6 Source #

Arguments

:: Doc 
-> Doc 
-> Doc

Beside

(<+>) infixl 6 Source #

Arguments

:: Doc 
-> Doc 
-> Doc

Beside, separated by space

hcat Source #

Arguments

:: [Doc] 
-> Doc

List version of <>

hsep Source #

Arguments

:: [Doc] 
-> Doc

List version of <+>

($$) infixl 5 Source #

Arguments

:: Doc 
-> Doc 
-> Doc

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

($+$) infixl 5 Source #

Arguments

:: Doc 
-> Doc 
-> Doc

Above, without dovetailing.

vcat Source #

Arguments

:: [Doc] 
-> Doc

List version of $$

sep Source #

Arguments

:: [Doc] 
-> Doc

Either hsep or vcat

cat Source #

Arguments

:: [Doc] 
-> Doc

Either hcat or vcat

fsep Source #

Arguments

:: [Doc] 
-> Doc

"Paragraph fill" version of sep

fcat Source #

Arguments

:: [Doc] 
-> Doc

"Paragraph fill" version of cat

nest Source #

Arguments

:: Int 
-> Doc 
-> Doc

Nested

hang Source #

Arguments

:: Doc 
-> Int 
-> Doc 
-> Doc
hang d1 n d2 = sep [d1, nest n d2]

punctuate Source #

Arguments

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

Predicates on documents

isEmpty Source #

Arguments

:: Doc 
-> PprM Bool

Returns True if the document is empty