- deriveTypeablePrim :: Name -> Int -> Q [Dec]
- type Constructor = (Name, Int, Maybe [Name], [Type])
- deriveDataPrim :: Name -> [Type] -> [Constructor] -> Q [Dec]
- deriveMinimalData :: Name -> Int -> Q [Dec]
- typeInfo :: Dec -> Q (Name, [Name], [Constructor])
- deriveOne :: Name -> Q [Dec]
- deriveOneDec :: Dec -> Q [Dec]
- deriveOneData :: Name -> Q [Dec]
- derive :: [Name] -> Q [Dec]
- deriveDec :: [Dec] -> Q [Dec]
- deriveData :: [Name] -> Q [Dec]
- deriveTypeable :: [Name] -> Q [Dec]
- deriveOneTypeable :: Name -> Q [Dec]
- deriveMinimalOne :: Name -> Q [Dec]
- deriveMinimal :: [Name] -> Q [Dec]
Takes the name of an algebraic data type, the number of type parameters it has and creates a Typeable instance for it.
Takes a name of a algebraic data type, the number of parameters it has and a list of constructor pairs. Each one of these constructor pairs consists of a constructor name and the number of type parameters it has. The function returns an automatically generated instance declaration for the Data class.
Doesn't do gunfold, dataCast1 or dataCast2
Derives the Data and Typeable instances for a single given data type.
Derives Data and Typeable instances for a list of data types. Order is irrelevant. This should be used in favour of deriveOne since Data and Typeable instances can often depend on other Data and Typeable instances - e.g. if you are deriving a large, mutually recursive data type. If you splice the derived instances in one by one you will need to do it in depedency order which is difficult in most cases and impossible in the mutually recursive case. It is better to bring all the instances into scope at once.
e.g. if data Foo = Foo Int is declared in an imported module then $(derive [''Foo]) will derive the instances for it
This function is much like deriveOne except that it brings into scope an instance of Data with minimal definitions. gfoldl will essentially leave a data structure untouched while gunfoldl, toConstr and dataTypeOf will yield errors.
This function is useful when you are certain that you will never wish to transform a particular data type. For instance you may be transforming another data type that contains other data types, some of which you wish to transform (perhaps recursively) and some which you just wish to return unchanged.
Sometimes you will be forced to use deriveMinimalOne because you do not have access to the contructors of the data type (perhaps because it is an Abstract Data Type). However, should the interface to the ADT be sufficiently rich it is possible to define you're own Data and Typeable instances.