GenericPretty-0.1.3: A generic, derivable, haskell pretty printer.

Safe HaskellNone

Text.PrettyPrint.GenericPretty

Description

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.

Synopsis

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

fullPPSource

Arguments

:: Out a 
=> a

The value to pretty print

-> PprStyle

The Outputable library style to use (default is defaultUserStyle)

-> Mode

The Pretty library style(mode) to use (default is PageMode)

-> 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.

outputTxt :: TextDetails -> IO () -> IO ()Source

outputTxt transforms the text into strings and outputs it directly. This is one example of a function that can handle the text conversion for fullPP.

outputStr :: TextDetails -> String -> StringSource

outputStr just leaves the text as a string. Another example of a function that can handle the text conversion for fullPP.

class Generic a

Representable types of kind *. This class is derivable in GHC with the DeriveRepresentable flag on.

Instances

Generic Bool 
Generic Char 
Generic Double 
Generic Float 
Generic Int 
Generic Ordering 
Generic () 
Generic [a] 
Generic (Maybe a) 
Generic (Either a b) 
Generic (a, b) 
Generic (a, b, c) 
Generic (a, b, c, d) 
Generic (a, b, c, d, e) 
Generic (a, b, c, d, e, f) 
Generic (a, b, c, d, e, f, g) 

class Out a whereSource

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

Methods

out :: Int -> a -> SDocSource

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

Instances

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) 

genOut :: (Generic a, GOut (Rep a)) => Int -> a -> SDocSource

default, generic, out method. User must use this when implementing Out by typing 'out = genOut'