Copyright | (C) 2015-2017 Ryan Scott |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Ryan Scott |
Portability | Template Haskell |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Exports functions to mechanically derive Eq
, Eq1
, and Eq2
instances.
Note that upstream GHC does not have the ability to derive Eq1
or Eq2
instances, but since the functionality to derive Eq
extends very naturally
Eq1
and Eq2
, the ability to derive the latter two classes is provided as a
convenience.
Eq
deriveEq :: Name -> Q [Dec] Source #
Generates an EqClass
instance declaration for the given data type or data
family instance.
makeEq :: Name -> Q Exp Source #
Generates a lambda expression which behaves like (==)
(without
requiring an EqClass
instance).
makeNotEq :: Name -> Q Exp Source #
Generates a lambda expression which behaves like (/=)
(without
requiring an EqClass
instance).
Eq1
deriveEq1 :: Name -> Q [Dec] Source #
Generates an Eq1
instance declaration for the given data type or data
family instance.
makeLiftEq :: Name -> Q Exp Source #
Generates a lambda expression which behaves like liftEq
(without
requiring an Eq1
instance).
This function is not available with transformers-0.4
.
makeEq1 :: Name -> Q Exp Source #
Generates a lambda expression which behaves like eq1
(without
requiring an Eq1
instance).
Eq2
deriveEq2 :: Name -> Q [Dec] Source #
Generates an Eq2
instance declaration for the given data type or data
family instance.
This function is not available with transformers-0.4
.
makeLiftEq2 :: Name -> Q Exp Source #
Generates a lambda expression which behaves like liftEq2
(without
requiring an Eq2
instance).
This function is not available with transformers-0.4
.
makeEq2 :: Name -> Q Exp Source #
Generates a lambda expression which behaves like eq2
(without
requiring an Eq2
instance).
This function is not available with transformers-0.4
.
deriveEq
limitations
Be aware of the following potential gotchas:
- Type variables of kind
*
are assumed to haveEq
constraints. Type variables of kind* -> *
are assumed to haveEq1
constraints. Type variables of kind* -> * -> *
are assumed to haveEq2
constraints. If this is not desirable, usemakeEq
or one of its cousins. - The
Eq1
class had a different definition intransformers-0.4
, and as a result,deriveEq1
implements different instances for thetransformers-0.4
Eq1
than it otherwise does. Also,makeLiftEq
is not available when this library is built againsttransformers-0.4
, only 'makeEq1. - The
Eq2
class is not available intransformers-0.4
, and as a result, neither are Template Haskell functions that deal withEq2
when this library is built againsttransformers-0.4
.