instant-generics-0.4.1: Generic programming library with a sum of products view

Copyright(c) 2011 Universiteit Utrecht
LicenseBSD3
Maintainergenerics@haskell.org
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

Generics.Instant.TH

Contents

Description

This module contains Template Haskell code that can be used to automatically generate the boilerplate code for the generic deriving library.

Synopsis

Main generator

deriveAll :: Name -> Q [Dec] Source

Given the type and the name (as string) for the type to derive, generate the Constructor instances and the Representable instance.

deriveAllL :: [Name] -> Q [Dec] Source

Same as deriveAll, but taking a list as input.

Individual generators

deriveConstructors :: Name -> Q [Dec] Source

Given a datatype name, derive datatypes and instances of class Constructor.

deriveRepresentable :: Name -> Q [Dec] Source

Given the type and the name (as string) for the Representable type synonym to derive, generate the Representable instance.

deriveRep :: Name -> Q [Dec] Source

Derive only the Rep type synonym. Not needed if deriveRepresentable is used.

Utilities

simplInstance :: Name -> Name -> Name -> Name -> Q [Dec] Source

Given the names of a generic class, a type to instantiate, a function in the class and the default implementation, generates the code for a basic generic instance.

gadtInstance :: Name -> Name -> Name -> Name -> Q [Dec] Source

Given the names of a generic class, a GADT type to instantiate, a function in the class and the default implementation, generates the code for a basic generic instance. This is tricky in general because we have to analyze the return types of each of the GADT constructors and give instances accordingly.