2 <label id="sec:Pretty">
5 This library contains Simon Peyton Jones' implementation of John
6 Hughes's pretty printer combinators.
13 data Doc -- the Document datatype
15 -- The primitive Doc values
20 integer :: Integer -> Doc
22 double :: Double -> Doc
23 rational :: Rational -> Doc
24 semi, comma, colon, space, equals :: Doc
25 lparen, rparen, lbrack, rbrack, lbrace, rbrace :: Doc
26 parens, brackets, braces :: Doc -> Doc
27 quotes, doubleQuotes :: Doc -> Doc
29 -- Combining Doc values
30 (<>) :: Doc -> Doc -> Doc -- Beside
31 hcat :: [Doc] -> Doc -- List version of <>
32 (<+>) :: Doc -> Doc -> Doc -- Beside, separated by space
33 hsep :: [Doc] -> Doc -- List version of <+>
34 ($$) :: Doc -> Doc -> Doc -- Above; if there is no
35 -- overlap it "dovetails" the two
36 vcat :: [Doc] -> Doc -- List version of $$
37 cat :: [Doc] -> Doc -- Either hcat or vcat
38 sep :: [Doc] -> Doc -- Either hsep or vcat
39 fcat :: [Doc] -> Doc -- ``Paragraph fill'' version of cat
40 fsep :: [Doc] -> Doc -- ``Paragraph fill'' version of sep
41 nest :: Int -> Doc -> Doc -- Nested
42 hang :: Doc -> Int -> Doc -> Doc
43 punctuate :: Doc -> [Doc] -> [Doc]
44 -- punctuate p [d1, ... dn] = [d1 <> p, d2 <> p, ... dn-1 <> p, dn]
46 -- Displaying Doc values
48 render :: Doc -> String -- Uses default style
49 renderStyle :: Style -> Doc -> String
50 data Style = Style { lineLength :: Int, -- In chars
51 ribbonsPerLine :: Float, -- Ratio of ribbon length
55 data Mode = PageMode -- Normal
56 | ZigZagMode -- With zig-zag cuts
57 | LeftMode -- No indentation, infinitely long lines
58 | OneLineMode -- All on one line