-- GenericPretty.cabal auto-generated by cabal init. For additional -- options, see -- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr. -- The name of the package. Name: GenericPretty -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented. Version: 1.1.0 -- A short (one-line) description of the package. Synopsis: A generic, derivable, haskell pretty printer. -- A longer description of the package. Description: *GenericPretty is a haskell library that provides support for automatic derivation of pretty printing functions on user defined data types. . *The Pretty library is used underneath, the work is done over 'Pretty.Doc' types. The library "MyPretty" is also provided. This library is a thin wrapper around the "Pretty" library and implements only 'Style' related features. These features are planned to be added to the Pretty library itself. When that happens "MyPretty" will become obsolete and will be replaced by "Pretty". . *The output provided by the library functions is identical to that of Prelude.show, except it has extra whitespace. . *This package requires the use of the new GHC.Generics features: . These features are present in versions of GHC >= 7.2. . *The Generics used are based on those described in the paper "A Generic Deriving Mechanism for Haskell" - by Magalhaes, Dijkstra, Jeuring and Loh in Proceedings of the third ACM Haskell symposium on Haskell (Haskell'2010), pp. 37-48, ACM, 2010: There are several changes from the original paper in the ghc implementation which are described here: . . *This generics mechanism supports deriving for all haskell datatypes EXCEPT for constrained datatypes. That is to say, datatypes which have a context will fail. . For instance, . "data (Eq a) => Constr a = Constr a" . will fail because of the (Eq a) context. . *Instalation instructions . 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.0.tar.gz" from this page. . 2. Unpack the file. If using a UNIX system, run . tar xzf GenericPretty-1.1.0.tar.gz . If on windows use your preffered unpacking utility(for instance, 7zip : ) . 3. Move to the correct directory: . cd GenericPretty-1.0.1 . 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: . *Basic example of usage . 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 . * For the above program to run the -XDeriveGeneric flag needs to be set. . 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 an example of custom 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. -- URL for the project homepage or repository. Homepage: https://github.com/HaggisMcMutton/GenericPretty -- The license under which the package is released. License: BSD3 -- The file containing the license text. License-file: LICENSE -- The package author(s). Author: Razvan Ranca -- An email address to which users can send suggestions, bug reports, -- and patches. Maintainer: ranca.razvan@gmail.com -- A copyright notice. -- Copyright: Category: Text, Generics, Pretty Printer Build-type: Simple -- Extra files to be distributed with the package, such as examples or -- a README. Extra-source-files: README TestSuite\SimpleTest.hs TestSuite\Tests.hs TestSuite\CustomTest.hs -- Constraint on the version of Cabal needed to build this package. Cabal-version: >=1.6 Library -- Modules exported by the library. Exposed-modules: Text.PrettyPrint.GenericPretty Text.PrettyPrint.MyPretty -- Packages needed in order to build this package. Build-depends: base >= 3 && < 5, ghc-prim, ghc >= 7.2 -- Modules not exported by this package. -- Other-modules: -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source. -- Build-tools: source-repository head type: git location: git@github.com:HaggisMcMutton/GenericPretty.git