The PPrinter package


A library that supports deriving of pretty printing functions on data types.

The interfaces of pretty printer used are based on that introduced in the paper: Philip Wadler, A Prettier Printer, The Fun of Programming, Cornerstones of Computing (2003): 223-243. original paper

The form of generic feature used is based on that introduced in the paper: Magalhaes, et al., A Generic Deriving Mechanism for Haskell, 3'rd ACM Symposium on Haskell, pp. 37-48, September 2010, The necessary information of implementation of GHC.Generics is described here:

The implementation of deriving part of API is based on that designed in the library: GenericPretty, the details are introduced here:

[Skip to ReadMe]


Versions0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.1.0, 0.1.0
Dependenciesbase (==4.8.*), containers (==0.5.*) [details]
AuthorYi Zhen
CategoryText, Generics, Pretty Printer
UploadedTue Oct 25 10:21:32 UTC 2016 by iamzhenyi



Maintainers' corner

For package maintainers and hackage trustees

Readme for PPrinter-0.1.0

a) How to install.

For *nix operating systems:
1. Go to the directory of ./src.
2. Using the command 'cabal configure' and then 'cabal install'

For windows or other operating systems, please check the official instructions for Haskell.

b) How to use this library.

1. Open a new Haskell file and adding the pragma 'DeriveGeneric'
2. Adding the line 'import Text.PPrinter'.
3. Define a new type by following the steps below:

i. Define a data type with deriving mechanism at first:

data Tree = Node String [Tree] deriving (Generic, Show)
You should add ‘deriving (Generic, Show)’ in the end, both of ‘Generic’ and ‘Show’ are necessary.

ii. Define an EMPTY Pretty instance of the data type:

instance Pretty (Tree)

iii. Define the exact data of the type:

tree                 = Node "aaa" [
                            Node "bbbbb" [
                               Node "ccc" [],
                               Node "dd" []
                            Node "eee" [],
                            Node "ffff" [
                              Node "gg" [],
                              Node "hhh" [],
                              Node "ii" []

iv. Output the data by the builtin functions:

pprint tree

Node "aaa"
     [Node "bbbbb"
           [Node "ccc" [],
            Node "dd" []],
      Node "eee" [],
      Node "ffff"
           [Node "gg" [],
            Node "hhh" [],
            Node "ii" []]]