The emgm package

[Tags:bsd3, library]

EMGM is a general-purpose library for generic programming with type classes.

The design is based on the idea of modeling algebraic datatypes as sum-of-product structures. Many datatypes can be modeled this way, and because they all share a common structure, we can write generic functions that work on this structure.

The primary features of the library are:

EMGM includes an important collection of datatypes (e.g. sum, product, and unit) and type classes (e.g. Generic and Rep). Everything you need for your own generic functions or datatypes can be found here.

These provide a wide range of functionality. For example, there is crush (Generics.EMGM.Functions.Crush), a generalization of the foldl/foldr functions, that allows you to flexibly extract the elements of a polymorphic container. Now, you can do many of the operations with your container that were previously only available for lists.

Different generic functions work with different kinds of types as well. For example, collect (Generics.EMGM.Functions.Collect) works with any fully applied type while bimap (Generics.EMGM.Functions.Map) only works with bifunctor types such as Either or (,) (pairs).

EMGM provides full support for standard types such as [] (lists), tuples, and Maybe as well as many types you define in your own code. Using the Template Haskell functions provided in Generics.EMGM.Derive, it is very simple to add support for using generic functions with your datatype

For more information on EMGM, see

[Skip to Readme]


Versions 0.1, 0.2, 0.3, 0.3.1, 0.4
Dependencies base (>=3.0 && <4.0), HUnit (==1.2.*), QuickCheck (==2.1.*), template-haskell (>=2.2 && <2.4) [details]
License BSD3
Copyright (c) 2008, 2009 Universiteit Utrecht
Author Sean Leather, José Pedro Magalhães, Alexey Rodriguez, Andres Löh
Stability experimental
Category Generics
Home page
Uploaded Thu Mar 5 23:15:23 UTC 2009 by SeanLeather
Downloads 1056 total (12 in the last 30 days)
0 []
Status Docs uploaded by user
Build status unknown [no reports yet]




testEnable the test configuration: Build the test executable, reduce build time.DisabledAutomatic
hpcEnable program coverage on test executable.DisabledAutomatic
nolibDon't build the library. This is useful for speeding up the modify-build-test loop. With "-ftest" (only), the build command will build both the library and the test executable. With "-ftest -fnolib", the build command builds only the test executable.DisabledAutomatic

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

For package maintainers and hackage trustees

Readme for emgm

Readme for emgm-0.3.1

Extensible and Modular Generics for the Masses

[Extensible and Modular Generics for the Masses] (EMGM) is a library for generic
programming in Haskell.

[Extensible and Modular Generics for the Masses]:


The primary features of EMGM include:

*  Datatype-generic programming using sum-of-product views
*  Large collection of ready-to-use generic functions
*  Included support for standard datatypes: lists, Maybe, tuples
*  Easy to add support for new datatypes
*  Type classes make writing new functions straightforward in a structurally
   inductive style
*  Generic functions are extensible with ad-hoc cases for arbitrary datatypes
*  Good performance of generic functions

The features of this distribution include:

*  The API is thoroughly documented with Haddock
*  Fully tested with QuickCheck and HUnit
*  Program coverage ensures that all useful code has been touched by tests
*  Tested on both Mac and Windows systems


EMGM has the following requirements:

*  [GHC] version 6.8.1 or later - It has been tested with versions 6.8.3 and 6.10.1.
*  [Cabal] library version 1.2.1 or later - It has been tested with versions and


Download & Installation

*If you have [cabal-install]*, you should use that to install the package,
because it will handle everything for you.

    cabal install emgm

*If you don't have cabal-install*, you must download the [emgm package] from
the HackageDB and install it manually. Get the `tar.gz` file and decompress it.

Once downloaded, use the following commands for configuring, building, and
installing the library.

    runghc Setup.lhs configure
    runghc Setup.lhs build
    runghc Setup.lhs install

To generate the Haddock documentation, run this commmand:

    runghc Setup.lhs haddock

For more details on the general options available, refer to the [Cabal User's

For more details on library-specific options, see the [Development] section.

[emgm package]:
[Cabal User's Guide]:
[Development]: #development


The API is documented using [Haddock] and available on the [emgm package] site.

[emgm package]:


You can find examples of using EMGM in the [`examples` directory] of the source

[`examples` directory]:

Bugs & Support

To report bugs, use the Google Code [project page for EMGM].

For general concerns and questions, use the [Generics mailing list].

[project page for EMGM]:
[Generics mailing list]:


EMGM is licensed under the so-called [BSD3 license]. See the included `LICENSE`

[BSD3 license]:


The research for EMGM originated with [Ralf Hinze]. It was extended with work by
[Bruno Oliveira] and [Andres Löh]. More details of the library functionality
were explored by [Alexey Rodriguez]. We are very grateful to all of these people
for the foundation on which this library was built.

The current authors and maintainers of EMGM are:

*  [Sean Leather]
*  [José Pedro Magalhães]
*  [Alexey Rodriguez]
*  [Andres Löh]

[Ralf Hinze]:
[Bruno Oliveira]:
[Andres Löh]:
[Alexey Rodriguez]:
[Sean Leather]:
[José Pedro Magalhães]:


If you're interesting in contributing to the development of EMGM or just in
playing with the code, there are some useful things to know.

### Source ###

The source can be checked out from its repository using [Subversion].

    svn checkout

You can also [view the files online].

[view the files online]:

### Requirements ###

In addition to the requirements for using the library, EMGM has the following
requirements for development:

*  Cabal library or later - This is preferred for uploading to HackageDB. Some
   issues were encountered with the current flags setup in emgm.cabal that gave
   errors in an older version of Cabal.
*  [QuickCheck] 2.1 - Required for testing.
*  [HUnit] 1.2 - Required for testing.


### Configuring ###

If you've been changing many files or the `emgm.cabal` file, you should clean
this distribution and build files.

    runghc Setup.lhs clean

In order to test the library, configure it with the following options:

    runghc Setup.lhs configure -ftest -fnolib

This enables building the test executable (while reducing the optimization level
to speed up the build) and disables building the library (thus also speeding up
the build). `nolib` is optional in case you actually do want to build the

To enable program coverage, add the `hpc` flag. This adds coverage only on the
test executable, so the `test` flag is required.

    runghc Setup.lhs configure -ftest -fnolib -fhpc

### Testing ###

After configuring with the `test` flag and building, you can run the test suite.

    runghc Setup.lhs test

You will see some output from both QuickCheck and HUnit. It should all work!

### Program coverage ###

If you have configured the library for HPC (see above), then you can get the
program coverage using the included script after running the test suite. This
uses the `hpc` command in your path and passes a number of flags excluding
modules that should be ignored for coverage purposes.

Run the script from the top-level directory to see its usage.

    runghc util/hpc.lhs

To get a simple report of the coverage, use the `report` option.

    runghc util/hpc.lhs report

To get a set of HTML files with code coverage indications, use the `markup`

    runghc util/hpc.lhs markup

At the end of this run, the command tells you where to find the HTML files.