deriving-compat-0.6.6: Backports of GHC deriving extensions
Copyright(C) 2015-2017 Ryan Scott
LicenseBSD-style (see the file LICENSE)
MaintainerRyan Scott
PortabilityTemplate Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Enum.Deriving

Description

Exports functions to mechanically derive Enum instances.

Synopsis

Enum

deriveEnum :: Name -> Q [Dec] Source #

Generates an Enum instance declaration for the given data type or data family instance.

makeSucc :: Name -> Q Exp Source #

Generates a lambda expression which behaves like succ (without requiring an Enum instance).

makePred :: Name -> Q Exp Source #

Generates a lambda expression which behaves like pred (without requiring an Enum instance).

makeToEnum :: Name -> Q Exp Source #

Generates a lambda expression which behaves like toEnum (without requiring an Enum instance).

makeFromEnum :: Name -> Q Exp Source #

Generates a lambda expression which behaves like fromEnum (without requiring an Enum instance).

makeEnumFrom :: Name -> Q Exp Source #

Generates a lambda expression which behaves like enumFrom (without requiring an Enum 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 have Enum constraints. If this is not desirable, use makeToEnum or one of its cousins.
  • Generated Enum instances for poly-kinded data family instances are likely to require the use of the TypeInType extension on GHC 8.0, 8.2, or 8.4.