The GenericPretty package

[Tags: bsd3, library]

For instance,

data (Eq a) => Constr a = Constr a

will fail because of the (Eq a) context.

The package is installed in the same way as any other package. If needed, instructions are provided below.

0. Make sure you have a version of ghc >= 7.2 installed and that you can use the runhaskell command from the command line.

1. Download the file GenericPretty-1.1.2.tar.gz from this page.

2. Unpack the file. If using a UNIX system, run

tar xzf GenericPretty-1.1.2.tar.gz

If on windows use your preferred unpacking utility(for instance, 7zip :

3. Move to the correct directory:

cd GenericPretty-1.1.2

4. Run the following haskell commands to install the library globally

runhaskell Setup configure

runhaskell Setup build

runhaskell Setup install

If something went wrong, you can check this page for more info, look at manual installation:

Here is a source file demonstrating the GenericPretty usage

import Text.PrettyPrint.GenericPretty

data Tree a = Leaf a | Node (Tree a) (Tree a) deriving (Generic)

instance (Out a) => Out (Tree a) where docPrec = genOut

tree :: Tree Int

tree = Node (Node (Leaf 333333333) (Leaf (-555555555))) (Leaf 777777777)

main = pp tree

This can be done either directly at the command line, by compiling with ghc -XDeriveGeneric or in the source code by using the LANGUAGE pragma (it seems I can't demonstrate the LANGUAGE pragma since cabal hates special characters. An example however is provided in the README file included in the package). Alternatively, for more information on the LANGUAGE pragma see here:

Besides setting the flag, one must derive Generic for the desired datatype by typing deriving (Generic) and write an instance of Out defining docPrec as docPrec = genOut. Then the pretty printing functions such as pp can be used on any data of that type.

For more details about the above example as well as examples of customizing the pretty printing please check the README file included in the package. For more information about the library itself and what it exports check the API linked further down this page.


Versions0.1.0, 0.1.1, 0.1.2, 0.1.3, 1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.7, 1.1.8, 1.1.9, 1.2.0, 1.2.1
Change logNone available
Dependenciesbase (>=3 && <5), ghc (>=7.2), ghc-prim
AuthorRazvan Ranca
CategoryText, Generics, Pretty Printer
Home page
Source repositoryhead: git clone
UploadedThu Aug 11 23:00:09 UTC 2011 by RazvanRanca
DistributionsLTSHaskell:1.2.1, NixOS:1.2.1, Stackage:1.2.1
Downloads3830 total (240 in last 30 days)
StatusDocs not available [build log]
Last success reported on 2015-05-21 [all 2 reports]



Maintainers' corner

For package maintainers and hackage trustees