Copyright | Copyright (C) 2010-2014 John MacFarlane |
---|---|
License | GNU GPL, version 2 or above |
Maintainer | John MacFarlane <jgm@berkeley.edu> |
Stability | alpha |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
A prettyprinting library for the production of text documents, including wrapped text, indentated blocks, and tables.
- data Doc
- render :: (Monoid a, IsString a) => Maybe Int -> Doc -> a
- cr :: Doc
- blankline :: Doc
- blanklines :: Int -> Doc
- space :: Doc
- text :: String -> Doc
- char :: Char -> Doc
- prefixed :: String -> Doc -> Doc
- flush :: Doc -> Doc
- nest :: Int -> Doc -> Doc
- hang :: Int -> Doc -> Doc -> Doc
- beforeNonBlank :: Doc -> Doc
- nowrap :: Doc -> Doc
- offset :: Doc -> Int
- height :: Doc -> Int
- lblock :: Int -> Doc -> Doc
- cblock :: Int -> Doc -> Doc
- rblock :: Int -> Doc -> Doc
- (<>) :: Monoid m => m -> m -> m
- (<+>) :: Doc -> Doc -> Doc
- ($$) :: Doc -> Doc -> Doc
- ($+$) :: Doc -> Doc -> Doc
- isEmpty :: Doc -> Bool
- empty :: Doc
- cat :: [Doc] -> Doc
- hcat :: [Doc] -> Doc
- hsep :: [Doc] -> Doc
- vcat :: [Doc] -> Doc
- vsep :: [Doc] -> Doc
- nestle :: Doc -> Doc
- chomp :: Doc -> Doc
- inside :: Doc -> Doc -> Doc -> Doc
- braces :: Doc -> Doc
- brackets :: Doc -> Doc
- parens :: Doc -> Doc
- quotes :: Doc -> Doc
- doubleQuotes :: Doc -> Doc
- charWidth :: Char -> Int
- realLength :: String -> Int
Documentation
render :: (Monoid a, IsString a) => Maybe Int -> Doc -> a Source
Renders a Doc
. render (Just n)
will use
a line length of n
to reflow text on breakable spaces.
render Nothing
will not reflow text.
A carriage return. Does nothing if we're at the beginning of a line; otherwise inserts a newline.
Inserts a blank line unless one exists already.
(blankline <> blankline
has the same effect as blankline
.
blanklines :: Int -> Doc Source
Inserts a blank lines unless they exists already.
(blanklines m <> blanklines n
has the same effect as blankline (max m n)
.
prefixed :: String -> Doc -> Doc Source
Uses the specified string as a prefix for every line of the inside document (except the first, if not at the beginning of the line).
hang :: Int -> Doc -> Doc -> Doc Source
A hanging indent. hang ind start doc
prints start
,
then doc
, leaving an indent of ind
spaces on every
line but the first.
beforeNonBlank :: Doc -> Doc Source
beforeNonBlank d
conditionally includes d
unless it is
followed by blank space.
lblock :: Int -> Doc -> Doc Source
lblock n d
is a block of width n
characters, with
text derived from d
and aligned to the left.
(<+>) :: Doc -> Doc -> Doc infixr 6 Source
Concatenate a list of Doc
s, putting breakable spaces
between them.
doubleQuotes :: Doc -> Doc Source
Wraps a Doc
in double quotes.
charWidth :: Char -> Int Source
Returns width of a character in a monospace font: 0 for a combining character, 1 for a regular character, 2 for an East Asian wide character.
realLength :: String -> Int Source
Get real length of string, taking into account combining and double-wide characters.