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

Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org

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.