deriving-compat
Backports of GHC deriving extensions
https://github.com/haskell-compat/deriving-compat
Version on this page: | 0.5.2 |
LTS Haskell 22.36: | 0.6.6 |
Stackage Nightly 2024-10-03: | 0.6.6 |
Latest on Hackage: | 0.6.6 |
deriving-compat-0.5.2@sha256:bcbed2e3eec0bb59ae91e4c21cd48691813987b673c21719aa29d04dab5a4aeb,7757
Module documentation for 0.5.2
- Data
- Data.Bounded
- Data.Deriving
- Data.Enum
- Data.Eq
- Data.Foldable
- Data.Functor
- Data.Ix
- Data.Ord
- Data.Traversable
- Text
- Text.Read
- Text.Show
deriving-compat
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
, andEq2
- Deriving
Ord
,Ord1
, andOrd2
- Deriving
Read
,Read1
, andRead2
- Deriving
Show
,Show1
, andShow2
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 derivingGeneric
instances, and modified in GHC 7.6 to allow derivation ofGeneric1
instances. UseGenerics.Deriving.TH
fromgeneric-deriving
to deriveGeneric(1)
using Template Haskell.DeriveLift
, which was introduced in GHC 8.0 for derivingLift
instances. UseLanguage.Haskell.TH.Lift
fromth-lift
to deriveLift
using Template Haskell.- The
Bifunctor
typeclass, which was introduced in GHC 7.10, as well as theBifoldable
andBitraversable
typeclasses, which were introduced in GHC 8.2. UseData.Bifunctor.TH
frombifunctors
to derive these typeclasses using Template Haskell.
Changes
0.5.2 [2018.09.13]
- Fix a bug (on GHC 8.7 and above) in which
deriveGND
/deriveVia
would generate ill-scoped code.
0.5.1 [2018.07.11]
- Have
deriveGND
/deriveVia
throw an error if an incorrect number of arguments are supplied to the type class.
0.5 [2018.07.01]
-
Backport the changes to
GeneralizedNewtypeDeriving
andDerivingVia
code generation from Trac #15290.As a result, code generated by
deriveGND
orderiveVia
now requires theInstanceSigs
andScopedTypeVariables
language extensions. On the other hand, the generated code no longer requires theImpredicativeTypes
extension (unless any class methods use higher-rank types). -
Allow building with
containers-0.6
andtemplate-haskell-2.14
.
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 theGeneralizedNewtypeDeriving
andDerivingVia
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
andOrd
instances for empty data types, simply returnTrue
andEQ
, respectively, without inspecting the arguments. - For derived
Read
instances for empty data types, simply returnpfail
(withoutparens
). - For derived
Show
instances for empty data types, inspect the argument (instead oferror
ing). In addition, addshowEmptyCaseBehavior
toShowOptions
, which configures whether derived instances for empty data types should use theEmptyCase
extension (this is disabled by default). - For derived
Functor
andTraversable
instances for empty data types, makefmap
andtraverse
strict in its argument. - For derived
Foldable
instances, do not error on empty data types. Instead, simply return the folded state (forfoldr
) ormempty
(forfoldMap
), without inspecting the arguments. - Add
FFTOptions
(Functor
/Foldable
/Traversable
options) toData.Functor.Deriving
, along with variants of existing functions that takeFFTOptions
as an argument. For now, the only configurable option is whether derived instances for empty data types should use theEmptyCase
extension (this is disabled by default).
- For derived
- Backport the fix to #13328. That is, when deriving
Functor
orTraversable
instances for data types where the last type variable is at phantom role, generatedfmap
/traverse
implementations now usecoerce
for efficiency. - Rename
emptyCaseBehavior
fromData.Functor.Deriving
tofftEmptyCaseBehavior
.
0.3.6 [2017.04.10]
- Make
deriveTraversable
useliftA2
in derived implementations oftraverse
when possible, now thatliftA2
is a class method ofApplicative
(as of GHC 8.2) - Make
deriveShow
useshowCommaSpace
, 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 derivingBounded
with TH. - Add
Data.Enum.Deriving
, which allows derivingEnum
with TH. - Add
Data.Ix.Deriving
, which allows derivingIx
with TH. - Fix bug in which derived
Show
instance would parenthesize the output too eagerly
0.3.2
- 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
0.3.1
- Allow deriving
Functor
andFoldable
instances for datatypes containing unboxed tuples - Microoptimization in derived instances of higher-order versions of
Eq
,Ord
,Read
, andShow
0.3
- Added
Data.Eq.Deriving
, which allows derivingEq
,Eq1
, andEq2
with TH. - Added
Data.Ord.Deriving
, which allows derivingOrd
,Ord1
, andOrd2
with TH. - Added
Data.Read.Deriving
, which allows derivingRead
,Read1
, andEq2
with TH. - Renamed
Text.Show.Deriving.Options
toShowOptions
so as to disambiguate it from the options datatypes in otherderiving-compat
modules.
0.2.2
- Fixed a bug in
Text.Show.Deriving
’s treatment of unlifted types
0.2.1
- Added
Text.Show.Deriving
, which allows derivingShow
,Show1
, andShow2
with TH.
0.2
- Added support for GHC 8.0
- Added
Data.Functor.Deriving
andData.Traversable.Deriving
, which allow derivingFunctor
andTraversable
with TH. - Added
Data.Deriving
, which reexports all other modules
0.1
- Initial commit