| Copyright | (c) 2011 Universiteit Utrecht |
|---|---|
| License | BSD3 |
| Maintainer | generics@haskell.org |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell98 |
Generics.Instant.TH
Description
This module contains Template Haskell code that can be used to automatically generate the boilerplate code for the generic deriving library.
- deriveAll :: Name -> Q [Dec]
- deriveAllL :: [Name] -> Q [Dec]
- deriveConstructors :: Name -> Q [Dec]
- deriveRepresentable :: Name -> Q [Dec]
- deriveRep :: Name -> Q [Dec]
- simplInstance :: Name -> Name -> Name -> Name -> Q [Dec]
- gadtInstance :: Name -> Name -> Name -> Name -> Q [Dec]
- genRepName :: Name -> Name
- typeVariables :: Info -> [TyVarBndr]
- tyVarBndrToName :: TyVarBndr -> Name
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.
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.
genRepName :: Name -> Name Source
typeVariables :: Info -> [TyVarBndr] Source
tyVarBndrToName :: TyVarBndr -> Name Source