Safe Haskell | None |
---|
GenericPretty is a haskell library that provides support for automatic derivation of pretty printing functions on user defined data types. The Outputable library is used underneath, the work is done over SDoc types.
The output provided by the library functions is identical to that of Prelude.show, except it has extra whitespace.
For examples of usage please see the README file.
- pp :: Out a => a -> IO ()
- prettyP :: Out a => Int -> Float -> a -> IO ()
- prettyStr :: Out a => a -> String
- fullPP :: Out a => a -> PprStyle -> Mode -> Int -> Float -> (TextDetails -> b -> b) -> b -> b
- outputTxt :: TextDetails -> IO () -> IO ()
- outputStr :: TextDetails -> String -> String
- class Generic a
- class Out a where
- genOut :: (Generic a, GOut (Rep a)) => Int -> a -> SDoc
Documentation
pp :: Out a => a -> IO ()Source
pp
is the default Pretty Printer,
it uses a line length of 80 and 1.5 ribbons per line (= 53 non-whitespace chars per line)
where ribbon is defined as the maximum length of text, excluding whitespace, on a single line
prettyP :: Out a => Int -> Float -> a -> IO ()Source
prettyP
is a partly customizable Pretty Printer
It takes the line length and ribbons per line as parameters
prettyStr :: Out a => a -> StringSource
prettyStr
returns the result as a string.
The returned value is identical to one made by Prelude.show, except for the extra whitespace
:: Out a | |
=> a | The value to pretty print |
-> PprStyle | The Outputable library style to use (default is defaultUserStyle) |
-> Mode | The |
-> Int | The maximum line length |
-> Float | The number of ribbons per line |
-> (TextDetails -> b -> b) | Function that handles the text conversion (default is 'outputTxt') |
-> b | The end element of the result ( eg: "" or putChar('\n') ) |
-> b | The pretty printed result |
fullPP
is a fully customizable Pretty Printer.
outputStr :: TextDetails -> String -> StringSource
class Generic a
Representable types of kind *. This class is derivable in GHC with the DeriveRepresentable flag on.
The class Out
is just a wrapper class for Outputable, which passes an extra parameter used to determine
when to wrap types up in parentheses
out
is the equivalent of Prelude.showsPrec
it generates output identical to show, except for the extra whitespace
outList :: Int -> [a] -> SDocSource
outList
mimics the behaviour of Prelude.showList
used mainly to output strings correctly, and not as lists of characters
Out Bool | |
Out Char | |
Out Int | |
Out Integer | |
Outputable a => Out a | |
Out a => Out [a] | |
Out a => Out (Maybe a) | |
(Out a, Out b) => Out (Either a b) | |
(Out a, Out b) => Out (a, b) | |
(Out a, Out b, Out c) => Out (a, b, c) | |
(Out a, Out b, Out c, Out d) => Out (a, b, c, d) | |
(Out a, Out b, Out c, Out d, Out e) => Out (a, b, c, d, e) | |
(Out a, Out b, Out c, Out d, Out e, Out f) => Out (a, b, c, d, e, f) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g) => Out (a, b, c, d, e, f, g) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g, Out h) => Out (a, b, c, d, e, f, g, h) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g, Out h, Out i) => Out (a, b, c, d, e, f, g, h, i) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g, Out h, Out i, Out j) => Out (a, b, c, d, e, f, g, h, i, j) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g, Out h, Out i, Out j, Out k) => Out (a, b, c, d, e, f, g, h, i, j, k) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g, Out h, Out i, Out j, Out k, Out l) => Out (a, b, c, d, e, f, g, h, i, j, k, l) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g, Out h, Out i, Out j, Out k, Out l, Out m) => Out (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g, Out h, Out i, Out j, Out k, Out l, Out m, Out n) => Out (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
(Out a, Out b, Out c, Out d, Out e, Out f, Out g, Out h, Out i, Out j, Out k, Out l, Out m, Out n, Out o) => Out (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) |