Portability | GHC |
---|---|
Stability | highly unstable |
Maintainer | Stephen Tetley <stephen.tetley@gmail.com> |
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 ()
Documentation
(<+>) :: Doc -> Doc -> DocSource
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.
integral :: Integral a => a -> DocSource
Show an "integral value" as a Doc via fromIntegral
.
Show the Int as hexadecimal, padding up to 4 digits if necessary.
No trucation occurs if the value has more than 4 digits.
fill :: Int -> Doc -> DocSource
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.
fillStringR :: Int -> String -> DocSource
fillStringL :: Int -> String -> DocSource
Left-padding version of fillStringR
.
enclose :: Doc -> Doc -> Doc -> DocSource
Enclose the final Doc within the first two.
There are no spaces between the documents:
enclose l r d = l <> d <> r
semiBraces :: [Doc] -> DocSource
Separate the list with a semicolon and enclose in curly braces.