Generic programming library for generalised deriving.

Version on this page:1.6.3
LTS Haskell 8.2:1.11.1
Stackage Nightly 2017-02-22:1.11.1
Latest on Hackage:1.11.1
BSD3 licensed by José Pedro Magalhães
Maintained by

Module documentation for 1.6.3

There are no documented modules for this package.

generic-deriving: Generic programming library for generalised deriving

Hackage Hackage Dependencies [Haskell Programming Language][] [BSD3 License][tl;dr Legal: BSD3] Build "generic-deriving package on Hackage" []: "The Haskell Programming Language" [tl;dr Legal: BSD3]: "BSD 3-Clause License (Revised)"

This package provides functionality for generalising the deriving mechanism in Haskell to arbitrary classes. It was first described in the paper:

The current implementation integrates with the new GHC Generics. See for more information. Template Haskell code is provided for supporting older GHCs.


1.11.1 [2016.09.10]

  • Fix Template Haskell regression involving data families
  • Convert examples to test suite
  • Backport missing Data and Typeable instances for Rec1, M1, (:*:), (:+:), and (:.:)


  • The behavior of functions in Generics.Deriving.TH have changed with respect to when type synonyms are generated for Rep(1) definitions. In particular:

    • By default, deriveRepresentable(1) will no longer define its Rep(1) type family instance in terms of the type synonym that has to be generated with deriveRep(1). Similarly, deriveAll(1) and deriveAll0And1 will no longer generate a type synonym. Instead, they will generate Generic(1) instances that directly define the Rep(1) instance inline. If you wish to revert to the old behavior, you will need to use the variants of those functions suffixed with -Options.
    • New functions makeRep0Inline and makeRep1Inline have been added which, for most purposes, should replace uses of makeRep0/makeRep0FromType and makeRep1/makeRep1FromType (but see the next bullet point for a caveat).
    • The use of deriveRep(1), makeRep0/makeRep0FromType, and makeRep1/makeRep1FromType are now discouraged, but those functions are still available. The reason is that on GHC 7.0/7.2/7.4, it is impossible to use makeRep0Inline/makeRep1Inline due to a GHC bug. Therefore, you must use makeRep0/makeRep1 and deriveRep(1) on GHC 7.0/7.2/7.4 out of necessity.

    These changes make dealing with Generic instances that involve PolyKinds and TypeInType much easier.

  • All functions suffixed in -WithKindSigs in Generics.Deriving.TH have been removed in favor of a more sensible -Options suffixing scheme. The ability to toggle whether explicit kind signatures are used on type variable binders has been folded into KindSigOptions, which is an explicit argument to deriveRep0Options/deriveRep1Options and also a field in the more general 'Options' data type.
  • Furthermore, the behavior of derived instances' kind signatures has changed. By default, the TH code will now always use explicit kind signatures whenever possible, regardless of whether you're working with plain data types or data family instances. This makes working with TypeInType less surprising, but at the cost of making it slightly more awkward to work with derived Generic1 instances that constrain kinds to * by means of (:.:).
  • Since Generic1 is polykinded on GHC 8.2 and later, the functions in Generics.Deriving.TH will no longer unify the kind of the last type parameter to be *.
  • Fix a bug in which makeRep (and similarly named functions) would not check whether the argument type can actually have a well kinded Generic(1) instance.
  • Backport missing Foldable and Traversable instances for Rec1


  • Renamed internal modules to avoid using apostrophes (averting this bug:


  • A new base-4-9 Cabal flag was added to more easily facilitate installing generic-deriving with manually installed versions of template-haskell.


  • Apply an optimization to generated to(1)/from(1) instances that factors out common occurrences of M1. See
  • Export internal typeclass names
  • Fix Haddock issues with GHC 7.8

  • Fix Haddock parsing issue on GHC 8.0


  • Backported MonadPlus and MonadZip instances for U1, and made the Functor, Foldable, Traversable, Alternative, and Monad instances for U1 lazier to correspond with base-4.9


  • Backported Enum, Bounded, Ix, Functor, Applicative, Monad,

MonadFix, MonadPlus, MonadZip, Foldable, Traversable, and Data instances (introduced in base-4.9) for datatypes in the Generics.Deriving.Base module


  • Fix TH regression on GHC 7.0


  • Added Generics.Deriving.Semigroup
  • Added GMonoid instance for Data.Monoid.Alt
  • Fixed a bug in the GEnum instances for unsigned Integral types
  • Added Safe/Trustworthy pragmas
  • Made instances polykinded where possible


  • On GHC 8.0 and up, Generics.Deriving.TH uses the new type literal-based machinery
  • Rewrote the Template Haskell code to be robust. Among other things, this fixes a bug with deriving Generic1 instances on GHC 7.8, and makes it easier to derive Generic1 instances for datatypes that utilize GHC 8.0's -XTypeInType extension.
  • Added deriveAll0 and makeRep0 for symmetry with deriveAll1 and makeRep1
  • AddedmakeRep0FromType and makeRep1FromType to make it easier to pass in the type instance (instead of having to pass each individual type variable, which can be error-prone)
  • Added functions with the suffix -WithKindSigs to allow generating type synonyms with explicit kind signatures in the presence of kind-polymorphic type variables. This is necessary for some datatypes that use -XTypeInType to have derived Generic(1) instances, but is not turned on by default since the TH kind inference is not perfect and would cause otherwise valid code to be rejected. Use only if you know what you are doing.
  • Fixed bug where a datatype with a single, nullary constructor would generate incorrect Generic instances
  • More sensible GEnum instances for fixed-size integral types
  • Added GCopoint, GEnum, GEq, GFoldable, GFunctor, GMonoid, GShow, and GTraversable instances for datatypes introduced in GHC 8.0
  • Backported Generic(1) instances added in GHC 8.0. Specifically, Generic instances for Complex (base-4.4 and later) ExitCode, and Version; and Generic1 instances for Complex (base-4.4 and later) and Proxy (base-4.7 and later). Added GEnum, GEq, GFoldable, GFunctor, GIx, GShow, and GTraversable instances for these datatypes where appropriate.


  • Allow deriving of Generic1 using Template Haskell
  • Allow deriving of Generic(1) for data families
  • Allow deriving of Generic(1) for constructor-less plain datatypes (but not data families, due to technical restrictions)
  • Support for unboxed representation types on GHC 7.11+
  • More GCopoint, GEnum, GEq, GFoldable, GFunctor, GIx, GMonoid, GShow, and GTraversable instances
  • The field accessors for the (:+:) type in Generics.Deriving.Base have been removed to be consistent with GHC.Generics
  • Ensure that TH generates definitions for isNewtype and packageName, if a recent-enough version of GHC is used
  • Ensure that TH-generated names are unique for a given data type's module and package (similar in spirit to Trac #10487)
  • Allow building on stage-1 compilers
comments powered byDisqus