|Maintainer||Stephen Tetley <firstname.lastname@example.org>|
Formatting combinators - pretty printers without the fitting.
Note - indentation support is very limited. Generally one should use a proper pretty printing library.
- data Doc
- type DocS = Doc -> Doc
- class Format a where
- empty :: Doc
- showsDoc :: ShowS -> Doc
- (<>) :: Doc -> Doc -> Doc
- (<+>) :: Doc -> Doc -> Doc
- vconcat :: Doc -> Doc -> Doc
- separate :: Doc -> [Doc] -> Doc
- hcat :: [Doc] -> Doc
- hsep :: [Doc] -> Doc
- vcat :: [Doc] -> Doc
- text :: String -> Doc
- char :: Char -> Doc
- int :: Int -> Doc
- integer :: Integer -> Doc
- integral :: Integral a => a -> Doc
- float :: Double -> Doc
- double :: Double -> Doc
- hex4 :: Int -> Doc
- space :: Doc
- comma :: Doc
- semicolon :: Doc
- line :: Doc
- fill :: Int -> Doc -> Doc
- fillStringR :: Int -> String -> Doc
- fillStringL :: Int -> String -> Doc
- punctuate :: Doc -> [Doc] -> Doc
- enclose :: Doc -> Doc -> Doc -> Doc
- squotes :: Doc -> Doc
- dquotes :: Doc -> Doc
- parens :: Doc -> Doc
- brackets :: Doc -> Doc
- braces :: Doc -> Doc
- angles :: Doc -> Doc
- lparen :: Doc
- rparen :: Doc
- lbracket :: Doc
- rbracket :: Doc
- lbrace :: Doc
- rbrace :: Doc
- langle :: Doc
- rangle :: Doc
- list :: [Doc] -> Doc
- tupled :: [Doc] -> Doc
- semiBraces :: [Doc] -> Doc
- indent :: Int -> Doc -> Doc
- writeDoc :: FilePath -> Doc -> IO ()
Horizontally concatenate two documents with a single space between them.
Vertically concatenate a list of documents, with a line break between each doc.
Create a document from a literal string.
The string should not contain newlines (though this is not enforced).
Create a document from a literal character.
The char should not be a tab or newline.
Show the Int as hexadecimal, padding up to 4 digits if necessary.
No trucation occurs if the value has more than 4 digits.
Fill a doc to the supplied length, padding the right-hand side with spaces.
Note - this function is expensive - it unrolls the functional representation of the String.
Also it should only be used for single line Doc's.
Enclose the final Doc within the first two.
There are no spaces between the documents:
enclose l r d = l <> d <> r
Horizontally indent a Doc.
Note - this space-prefixes the Doc on the current line. It does not indent subsequent lines if the Doc spans multiple lines.