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 Enum
instances.
Enum
deriveEnum :: Name -> Q [Dec] Source #
Generates an Enum
instance declaration for the given data type or data
family instance.
makeEnumFromThen :: Name -> Q Exp Source #
Generates a lambda expression which behaves like enumFromThen
(without
requiring an Enum
instance).
deriveEnum
limitations
Be aware of the following potential gotchas:
- Type variables of kind
*
are assumed to haveEnum
constraints. If this is not desirable, usemakeToEnum
or one of its cousins. - Generated
Enum
instances for poly-kinded data family instances are likely to require the use of theTypeInType
extension on GHC 8.0, 8.2, or 8.4.