The PPrinter package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

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, http://dx.doi.org/10.1145/1863523.1863529. The necessary information of implementation of GHC.Generics is described here: https://hackage.haskell.org/package/base-4.9.0.0/docs/GHC-Generics.html#g:1.

The implementation of deriving part of API is based on that designed in the library: GenericPretty, the details are introduced here: https://hackage.haskell.org/package/GenericPretty


[Skip to ReadMe]

Properties

Versions0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.1.0, 0.1.0
Change logNone available
Dependenciesbase (==4.8.*), containers (==0.5.*) [details]
LicenseBSD3
AuthorYi Zhen
Maintainers1563190@sms.ed.ac.uk
CategoryText, Generics, Pretty Printer
UploadedTue Oct 25 10:21:32 UTC 2016 by iamzhenyi

Modules

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for PPrinter-0.1.0

[back to package description]
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" []]]