Copyright | (c) 2011 Simon Meier |
---|---|
License | GPL v3 (see LICENSE) |
Maintainer | Simon Meier <iridcode@gmail.com> |
Safe Haskell | Safe |
Language | Haskell98 |
Text.PrettyPrint.Class
Contents
Description
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 :: *
- ($--$) :: Document d => d -> d -> d
- emptyDoc :: Document d => d
- (<>) :: Monoid m => m -> m -> m
- semi :: Document d => d
- colon :: Document d => d
- comma :: Document d => d
- space :: Document d => d
- equals :: Document d => d
- lparen :: Document d => d
- rparen :: Document d => d
- lbrack :: Document d => d
- rbrack :: Document d => d
- lbrace :: Document d => d
- rbrace :: 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 :: Document d => d -> d
- doubleQuotes :: Document d => d -> d
- parens :: Document d => d -> d
- brackets :: Document d => d -> d
- braces :: 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
class (Monoid d, NFData d) => Document d where #
Minimal complete definition
char, text, zeroWidthText, (<->), hcat, hsep, ($$), ($-$), vcat, sep, cat, fsep, fcat, nest, caseEmptyDoc
renderStyle :: Style -> Doc -> String #
defaultStyle :: Style #
The default Style
.
A rendering style. Allows us to specify constraints to choose among the many different rendering options.
Constructors
Style | |
Fields
|
Rendering mode.
Constructors
PageMode | Normal rendering ( |
ZigZagMode | With zig-zag cuts. |
LeftMode | No indentation, infinitely long lines ( |
OneLineMode | All on one line, |
($--$) :: Document d => d -> d -> d infixl 5 #
Vertical concatentation of two documents with an empty line in between.
doubleQuotes :: Document d => d -> d #
Additional combinators
Arguments
:: 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.
Arguments
:: 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 -> d #
Nest document between two strings and indent body by length lead + 1
.
nestShortNonEmpty :: Document d => Int -> d -> d -> d -> d #
Like nestShort
but doesn't print the lead and finish, if the document is
empty.
nestShortNonEmpty' :: Document d => String -> String -> d -> d #
Like nestShort'
but doesn't print the lead and finish, if the document is
empty.
fixedWidthText :: Document d => Int -> String -> d #
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.