Maintainer | Simon Meier <iridcode@gmail.com> |
---|---|
Safe Haskell | Safe-Infered |
Document
class allowing to have different interpretations of the
HughesPJ pretty-printing combinators.
- data Doc
- class (Monoid d, NFData d) => Document d where
- isEmpty :: Doc -> Bool
- render :: Doc -> String
- renderStyle :: Style -> Doc -> String
- defaultStyle :: Style
- data Style = Style {
- mode :: Mode
- lineLength :: Int
- ribbonsPerLine :: Float
- data Mode
- = PageMode
- | ZigZagMode
- | LeftMode
- | OneLineMode
- ($--$) :: Document d => d -> d -> d
- emptyDoc :: Document d => d
- (<>) :: Monoid m => m -> m -> m
- semi, rbrace, lbrace, rbrack, lbrack, rparen, lparen, equals, space, comma, colon :: Document d => d
- int :: Document d => Int -> d
- integer :: Document d => Integer -> d
- float :: Document d => Float -> d
- double :: Document d => Double -> d
- rational :: Document d => Rational -> d
- quotes, braces, brackets, parens, doubleQuotes :: Document d => d -> d
- hang :: Document d => d -> Int -> d -> d
- punctuate :: Document d => d -> [d] -> [d]
- nestBetween :: Document d => Int -> d -> d -> d -> d
- nestShort :: Document d => Int -> d -> d -> d -> d
- nestShort' :: Document d => String -> String -> d -> d
- nestShortNonEmpty :: Document d => Int -> d -> d -> d -> d
- nestShortNonEmpty' :: Document d => String -> String -> d -> d
- fixedWidthText :: Document d => Int -> String -> d
- symbol :: Document d => String -> d
- numbered :: Document d => d -> [d] -> d
- numbered' :: Document d => [d] -> d
Documentation
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.
class (Monoid d, NFData d) => Document d whereSource
zeroWidthText :: String -> dSource
caseEmptyDoc :: d -> d -> d -> dSource
renderStyle :: Style -> Doc -> String
Render the Doc
to a String using the given Style
.
The default Style
.
data Style
A rendering style.
Style | |
|
data Mode
Rendering mode.
PageMode | Normal |
ZigZagMode | With zig-zag cuts |
LeftMode | No indentation, infinitely long lines |
OneLineMode | All on one line |
($--$) :: Document d => d -> d -> dSource
Vertical concatentation of two documents with an empty line in between.
semi, rbrace, lbrace, rbrack, lbrack, rparen, lparen, equals, space, comma, colon :: Document d => dSource
Additional combinators
:: Document d | |
=> Int | Indent of body |
-> d | Leading document |
-> d | Finishing document |
-> d | Body document |
-> d |
Nest a document surrounded by a leading and a finishing document breaking lead, body, and finish onto separate lines, if they don't fit on a single line.
:: Document d | |
=> Int | Indent of body |
-> d | Leading document |
-> d | Finishing document |
-> d | Body document |
-> d |
Nest a document surrounded by a leading and a finishing document with an non-compulsory break between lead and body.
nestShort' :: Document d => String -> String -> d -> dSource
Nest document between two strings and indent body by length lead + 1
.
nestShortNonEmpty :: Document d => Int -> d -> d -> d -> dSource
Like nestShort
but doesn't print the lead and finish, if the document is
empty.
nestShortNonEmpty' :: Document d => String -> String -> d -> dSource
Like nestShort'
but doesn't print the lead and finish, if the document is
empty.
fixedWidthText :: Document d => Int -> String -> dSource
Output text with a fixed width: if it is smaller then nothing happens, otherwise care is taken to make the text appear having the given width.