Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Extends 'PrettyPrint'
.
Synopsis
- module Text.PrettyPrint
- class Pretty a where
- pretty :: a -> Doc
- prettyPrec :: Int -> a -> Doc
- prettyShow :: Pretty a => a -> String
- parensIf :: Bool -> Doc -> Doc
- ($++$) :: Doc -> Doc -> Doc
- vsep :: [Doc] -> Doc
- vcat' :: [Doc] -> Doc
- (<=>) :: Doc -> Doc -> Doc
- prettyList :: Int -> Doc -> Doc -> Doc -> Doc -> [Doc] -> Doc
- codeblock :: Int -> [Doc] -> Doc
Documentation
module Text.PrettyPrint
Overloaded function pretty
.
Instances
Pretty Cat Source # | |
Pretty String Source # | |
Pretty Integer Source # | |
Pretty Int Source # | |
(IsFun f, Pretty f) => Pretty (Exp' f) Source # | |
Pretty function => Pretty (Rul function) Source # | |
Pretty a => Pretty (WithPosition a) Source # | |
Defined in BNFC.CF pretty :: WithPosition a -> Doc Source # prettyPrec :: Int -> WithPosition a -> Doc Source # |
parensIf :: Bool -> Doc -> Doc Source #
Put parens
around document if given condition is true.
>>>
parensIf True "foo"
(foo)
>>>
parensIf False "bar"
bar
($++$) :: Doc -> Doc -> Doc Source #
Separate vertically by a blank line.
>>>
"foo" $++$ "bar"
foo bar
>>>
"foo" $++$ empty
foo
vcat' :: [Doc] -> Doc Source #
List version of $+$
.
>>>
vcat' [text "abc", nest 4 (text "def")]
abc def
(<=>) :: Doc -> Doc -> Doc Source #
Pretty print separator with = (for assignments...).
>>>
"a" <=> "123"
a = 123
:: Int | Indentation. |
-> Doc | Preamble. |
-> Doc | Left parenthesis. |
-> Doc | Right parenthesis. |
-> Doc | Separator (usually not including spaces). |
-> [Doc] | List item. |
-> Doc |
Print a list of 0-1 elements on the same line as some preamble and from 2 elements on the following lines, indented.
>>>
prettyList 2 ("foo" <+> equals) lbrack rbrack comma []
foo = []>>>
prettyList 2 ("foo" <+> equals) lbrack rbrack comma [ "a" ]
foo = [a]>>>
prettyList 2 ("foo" <+> equals) lbrack rbrack comma [ "a", "b" ]
foo = [ a , b ]
Used in the Agda backend.