Portability  portable 

Stability  stable 
Maintainer  Warren Harris <warrensomebody@gmail.com> 
Safe Haskell  SafeInferred 
A wrapper around the John Hughes's and Simon Peyton Jones's Pretty Printer combinators based on the ReaderT monad transformer, allowing lookups to be performed during the prettyprinting process.
 data Doc
 data TextDetails
 char :: (Monad m, Applicative m) => Char > m Doc
 text :: (Monad m, Applicative m) => String > m Doc
 ptext :: (Monad m, Applicative m) => String > m Doc
 sizedText :: (Monad m, Applicative m) => Int > String > m Doc
 zeroWidthText :: (Monad m, Applicative m) => String > m Doc
 int :: (Monad m, Applicative m) => Int > m Doc
 integer :: (Monad m, Applicative m) => Integer > m Doc
 float :: (Monad m, Applicative m) => Float > m Doc
 double :: (Monad m, Applicative m) => Double > m Doc
 rational :: (Monad m, Applicative m) => Rational > m Doc
 semi :: (Monad m, Applicative m) => m Doc
 comma :: (Monad m, Applicative m) => m Doc
 colon :: (Monad m, Applicative m) => m Doc
 space :: (Monad m, Applicative m) => m Doc
 equals :: (Monad m, Applicative m) => m Doc
 lparen :: (Monad m, Applicative m) => m Doc
 rparen :: (Monad m, Applicative m) => m Doc
 lbrack :: (Monad m, Applicative m) => m Doc
 rbrack :: (Monad m, Applicative m) => m Doc
 lbrace :: (Monad m, Applicative m) => m Doc
 rbrace :: (Monad m, Applicative m) => m Doc
 parens :: (Monad m, Applicative m) => m Doc > m Doc
 brackets :: (Monad m, Applicative m) => m Doc > m Doc
 braces :: (Monad m, Applicative m) => m Doc > m Doc
 quotes :: (Monad m, Applicative m) => m Doc > m Doc
 doubleQuotes :: (Monad m, Applicative m) => m Doc > m Doc
 empty :: (Monad m, Applicative m) => m Doc
 (<>) :: (Monad m, Applicative m) => m Doc > m Doc > m Doc
 (<+>) :: (Monad m, Applicative m) => m Doc > m Doc > m Doc
 hcat :: (Monad m, Applicative m) => m [Doc] > m Doc
 hsep :: (Monad m, Applicative m) => m [Doc] > m Doc
 ($$) :: (Monad m, Applicative m) => m Doc > m Doc > m Doc
 ($+$) :: (Monad m, Applicative m) => m Doc > m Doc > m Doc
 vcat :: (Monad m, Applicative m) => m [Doc] > m Doc
 sep :: (Monad m, Applicative m) => m [Doc] > m Doc
 cat :: (Monad m, Applicative m) => m [Doc] > m Doc
 fsep :: (Monad m, Applicative m) => m [Doc] > m Doc
 fcat :: (Monad m, Applicative m) => m [Doc] > m Doc
 nest :: (Monad m, Applicative m) => Int > m Doc > m Doc
 hang :: (Monad m, Applicative m) => m Doc > Int > m Doc > m Doc
 punctuate :: (Monad m, Applicative m) => m Doc > m [Doc] > m [Doc]
 isEmpty :: (Monad m, Applicative m) => m Doc > m Bool
 render :: (Monad m, Applicative m) => m Doc > m String
 data Style = Style {
 mode :: Mode
 lineLength :: Int
 ribbonsPerLine :: Float
 style :: Style
 renderStyle :: (Monad m, Applicative m) => Style > m Doc > m String
 data Mode
 = PageMode
  ZigZagMode
  LeftMode
  OneLineMode
 fullRender :: (Monad m, Applicative m) => Mode > Int > Float > (TextDetails > a > a) > a > m Doc > m a
The document type
data Doc
The abstract type of documents. A Doc represents a *set* of layouts. A Doc with no occurrences of Union or NoDoc represents just one layout.
data TextDetails
The TextDetails data type
A TextDetails represents a fragment of text that will be output at some point.
Constructing documents
Converting values into documents
char :: (Monad m, Applicative m) => Char > m DocSource
A document of height and width 1, containing a literal character.
ptext :: (Monad m, Applicative m) => String > m DocSource
Same as text
. Used to be used for Bytestrings.
sizedText :: (Monad m, Applicative m) => Int > String > m DocSource
Some text with any width. (text s = sizedText (length s) s
)
zeroWidthText :: (Monad m, Applicative m) => String > m DocSource
Some text, but without any width. Use for nonprinting text such as a HTML or Latex tags
Simple derived documents
semi :: (Monad m, Applicative m) => m DocSource
A ';' character
comma :: (Monad m, Applicative m) => m DocSource
A ',' character
colon :: (Monad m, Applicative m) => m DocSource
A :
character
space :: (Monad m, Applicative m) => m DocSource
A space character
equals :: (Monad m, Applicative m) => m DocSource
A '=' character
lparen :: (Monad m, Applicative m) => m DocSource
A '(' character
rparen :: (Monad m, Applicative m) => m DocSource
A ')' character
lbrack :: (Monad m, Applicative m) => m DocSource
A '[' character
rbrack :: (Monad m, Applicative m) => m DocSource
A ']' character
lbrace :: (Monad m, Applicative m) => m DocSource
A '{' character
rbrace :: (Monad m, Applicative m) => m DocSource
A '}' character
Wrapping documents in delimiters
doubleQuotes :: (Monad m, Applicative m) => m Doc > m DocSource
Wrap document in "..."
Combining documents
empty :: (Monad m, Applicative m) => m DocSource
($$) :: (Monad m, Applicative m) => m Doc > m Doc > m DocSource
Above, except that if the last line of the first argument stops at least one position before the first line of the second begins, these two lines are overlapped. For example:
text "hi" $$ nest 5 (text "there")
lays out as
hi there
rather than
hi there
nest :: (Monad m, Applicative m) => Int > m Doc > m DocSource
Nest (or indent) a document by a given number of positions
(which may also be negative). nest
satisfies the laws:
nest
0 x = xnest
k (nest
k' x) =nest
(k+k') xnest
k (x<>
y) =nest
k z<>
nest
k ynest
k (x$$
y) =nest
k x$$
nest
k ynest
kempty
=empty

x
, if<>
nest
k y = x<>
yx
nonempty
The side condition on the last law is needed because
empty
is a left identity for <>
.
hang :: (Monad m, Applicative m) => m Doc > Int > m Doc > m DocSource
hang d1 n d2 = sep [d1, nest n d2]
punctuate :: (Monad m, Applicative m) => m Doc > m [Doc] > m [Doc]Source
punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn1 <> p, dn]
Predicates on documents
Rendering documents
Default rendering
render :: (Monad m, Applicative m) => m Doc > m StringSource
Render the Doc
to a String using the default Style
.
Rendering with a particular style
data Style
A rendering style.
Style  

renderStyle :: (Monad m, Applicative m) => Style > m Doc > m StringSource
Render the Doc
to a String using the given Style
.
data Mode
Rendering mode.
PageMode  Normal 
ZigZagMode  With zigzag cuts 
LeftMode  No indentation, infinitely long lines 
OneLineMode  All on one line 
General rendering
:: (Monad m, Applicative m)  
=> Mode  Rendering mode 
> Int  Line length 
> Float  Ribbons per line 
> (TextDetails > a > a)  What to do with text 
> a  What to do at the end 
> m Doc  The document 
> m a  Result 
The general rendering interface.