| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.LargeHashable.TH
Documentation
deriveLargeHashable :: Name -> Q [Dec] Source
Template Haskell function to automatically derive
instances of LargeHashable. The derived instances first
calls updateHash with an unique identifier number for
every constructor, followed by updateHash calls for every
field of the constructor (if existent). It also works for
type families.
E. g. for the following code
data BlaFoo a = Foo
| Bar Int a
| Baz a a
$(deriveLargeHashable ''BlaFoo)
The following instance gets generated:
instance LargeHashable a_apg8 =>
LargeHashable (BlaFoo a_apg8) where
updateHash Foo = updateHash (0 :: Foreign.C.Types.CULong)
updateHash (Bar a b)
= (((updateHash (1 :: Foreign.C.Types.CULong)) >> (updateHash a))
>> (updateHash b))
updateHash (XY a b)
= (((updateHash (2 :: Foreign.C.Types.CULong)) >> (updateHash a))
>> (updateHash b))
Arguments
| :: Name | |
| -> ([TypeQ] -> [PredQ]) | Function mapping the type variables in the instance head to the additional constraints |
| -> Q [Dec] |
Derive a LargeHashable instance with extra constraints in the
context of the instance.
deriveLargeHashableNoCtx :: Name -> Q [Dec] Source
Derive a LargeHashable instance with no constraints in the context of the instance.
deriveLargeHashableCustomCtx Source
Arguments
| :: Name | |
| -> ([TypeQ] -> [PredQ] -> [PredQ]) | Function mapping the type variables in the instance head and the constraints that would normally be generated to the constraints that should be generated. |
| -> Q [Dec] |
Derive a LargeHashable instance with a completely custom instance context.