BSD3 licensed by Ryan Scott
Maintained by Ryan Scott

Module documentation for 0.3.6


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

Provides Template Haskell functions that mimic deriving extensions that were introduced or modified in recent versions of GHC. Currently, the following typeclasses/extensions are covered:

  • Deriving Bounded
  • Deriving Enum
  • Deriving Ix
  • Deriving Eq, Eq1, and Eq2
  • Deriving Ord, Ord1, and Ord2
  • Deriving Read, Read1, and Read2
  • Deriving Show, Show1, and Show2
  • DeriveFoldable
  • DeriveFunctor
  • DeriveTraversable
  • GeneralizedNewtypeDeriving (with GHC 8.2 or later)
  • DerivingVia (with GHC 8.2 or later)

See the Data.Deriving module for a full list of backported changes.

Note that some recent GHC typeclasses/extensions are not covered by this package:

  • DeriveDataTypeable
  • DeriveGeneric, which was introducted in GHC 7.2 for deriving Generic instances, and modified in GHC 7.6 to allow derivation of Generic1 instances. Use Generics.Deriving.TH from generic-deriving to derive Generic(1) using Template Haskell.
  • DeriveLift, which was introduced in GHC 8.0 for deriving Lift instances. Use Language.Haskell.TH.Lift from th-lift to derive Lift using Template Haskell.
  • The Bifunctor typeclass, which was introduced in GHC 7.10, as well as the Bifoldable and Bitraversable typeclasses, which were introduced in GHC 8.2. Use Data.Bifunctor.TH from bifunctors to derive these typeclasses using Template Haskell.


0.4.3 [2018.06.16]

  • Fix a bug that caused debug-enabled GHC builds to panic when generating code from this library (see Trac #15270). The fix only affects the library's internals, so no changes are user-facing.

0.4.2 [2018.05.14]

  • Backport the fixes for GHC Trac #14364 and #14918, which significantly improve the compliation times of derived Read instances.

0.4.1 [2018.02.04]

  • Add Data.Deriving.Via, which allows emulating the behavior of the GeneralizedNewtypeDeriving and DerivingVia extensions.
  • Test suite fixes for GHC 8.4.

0.4 [2017.12.07]

  • Incorporate changes from the EmptyDataDeriving proposal (which is in GHC as of 8.4): For derived Eq and Ord instances for empty data types, simply return True and EQ, respectively, without inspecting the arguments. For derived Read instances for empty data types, simply return pfail (without parens). For derived Show instances for empty data types, inspect the argument (instead of erroring). In addition, add showEmptyCaseBehavior to ShowOptions, which configures whether derived instances for empty data types should use the EmptyCase extension (this is disabled by default). For derived Functor and Traversable instances for empty data types, make fmap and traverse strict in its argument. For derived Foldable instances, do not error on empty data types. Instead, simply return the folded state (for foldr) or mempty (for foldMap), without inspecting the arguments. Add FFTOptions (Functor/Foldable/Traversable options) to Data.Functor.Deriving, along with variants of existing functions that take FFTOptions as an argument. For now, the only configurable option is whether derived instances for empty data types should use the EmptyCase extension (this is disabled by default).
  • Backport the fix to #13328. That is, when deriving Functor or Traversable instances for data types where the last type variable is at phantom role, generated fmap/traverse implementations now use coerce for efficiency.
  • Rename emptyCaseBehavior from Data.Functor.Deriving to fftEmptyCaseBehavior.

0.3.6 [2017.04.10]

  • Make deriveTraversable use liftA2 in derived implementations of traverse when possible, now that liftA2 is a class method of Applicative (as of GHC 8.2)
  • Make deriveShow use showCommaSpace, a change introduced in GHC 8.2

0.3.5 [2016.12.12]

  • Fix bug in which derived Ord instances for datatypes with many constructors would fail to typecheck

0.3.4 [2016.10.20]

  • Fix bug in which infix record selectors weren't shown with parentheses in derived Show instances
  • Fix bug in which record selectors weren't parsed correctly in derived Read instances

0.3.3 [2016.09.11]

  • Add Data.Bounded.Deriving, which allows deriving Bounded with TH.
  • Add Data.Enum.Deriving, which allows deriving Enum with TH.
  • Add Data.Ix.Deriving, which allows deriving Ix with TH.
  • Fix bug in which derived Show instance would parenthesize the output too eagerly


  • Incorporate a fix to GHC Trac #10858, which will be introduced in GHC 8.2
  • Fix bug in which derived Ord instances accidentally swapped their less-than(-or-equal-to) and greater-than(-or-equal-to) methods
  • Fix GHC HEAD build


  • Allow deriving Functor and Foldable instances for datatypes containing unboxed tuples
  • Microoptimization in derived instances of higher-order versions of Eq, Ord, Read, and Show


  • Added Data.Eq.Deriving, which allows deriving Eq, Eq1, and Eq2 with TH.
  • Added Data.Ord.Deriving, which allows deriving Ord, Ord1, and Ord2 with TH.
  • Added Data.Read.Deriving, which allows deriving Read, Read1, and Eq2 with TH.
  • Renamed Text.Show.Deriving.Options to ShowOptions so as to disambiguate it from the options datatypes in other deriving-compat modules.


  • Fixed a bug in Text.Show.Deriving's treatment of unlifted types


  • Added Text.Show.Deriving, which allows deriving Show, Show1, and Show2 with TH.


  • Added support for GHC 8.0
  • Added Data.Functor.Deriving and Data.Traversable.Deriving, which allow deriving Functor and Traversable with TH.
  • Added Data.Deriving, which reexports all other modules


  • Initial commit
comments powered byDisqus