Options that further configure how the functions in Data.Functor.Classes.Generic should behave. Currently, the Options have no effect (but this may change in the future).
Moduletransformers-compat-0.8Haskell2010
Data.Functor.Classes.Generic
Functions to generically derive C.Eq1, C.Ord1, C.Read1, and C.Show1
instances from Data.Functor.Classes.
Synopsis
- data Options
- value defaultOptions
- value latestGHCOptions
- value liftEqDefault
- value liftEqOptions
- value liftCompareDefault
- value liftCompareOptions
- value liftReadsPrecDefault
- value liftReadsPrecOptions
- value liftShowsPrecDefault
- value liftShowsPrecOptions
- newtype FunctorClassesDefault
- Packagetransformers-compat-0.8
- Exports12
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceGeneric.hs
Options
Options that match the behavior of the installed version of GHC.
Options that match the behavior of the most recent GHC release.
Eq1
Like liftEqDefault, but with configurable Options. Currently, the Options have no effect (but this may change in the future).
Ord1
A sensible default liftCompare implementation for Generic1 instances.
Like liftCompareDefault, but with configurable Options. Currently, the Options have no effect (but this may change in the future).
Read1
A sensible default liftReadsPrec implementation for Generic1 instances.
Like liftReadsPrecDefault, but with configurable Options. Currently, the Options have no effect (but this may change in the future).
Show1
A sensible default liftShowsPrec implementation for Generic1 instances.
Like liftShowsPrecDefault, but with configurable Options. Currently, the Options have no effect (but this may change in the future).
GenericFunctorClasses
An adapter newtype, suitable for DerivingVia. Its Eq1, Ord1,
Read1, and Show1 instances leverage Generic1-based defaults.
Constructors
Instances8Eq1, Ord1, Read1, Show1, Eq, Ord, …
(GEq1 (Rep1 f), Generic1 f) => Eq1 (FunctorClassesDefault f)Defined in transformers-compat-0.8 · Data.Functor.Classes.Generic.Internal(GOrd1 (Rep1 f), Generic1 f) => Ord1 (FunctorClassesDefault f)Defined in transformers-compat-0.8 · Data.Functor.Classes.Generic.Internal(GRead1 (Rep1 f), Generic1 f) => Read1 (FunctorClassesDefault f)Defined in transformers-compat-0.8 · Data.Functor.Classes.Generic.Internal(GShow1 (Rep1 f), Generic1 f) => Show1 (FunctorClassesDefault f)Defined in transformers-compat-0.8 · Data.Functor.Classes.Generic.Internal(GEq (Rep1 f a), Generic1 f) => Eq (FunctorClassesDefault f a)Defined in transformers-compat-0.8 · Data.Functor.Classes.Generic.Internal(GOrd (Rep1 f a), Generic1 f) => Ord (FunctorClassesDefault f a)Defined in transformers-compat-0.8 · Data.Functor.Classes.Generic.Internal(GRead (Rep1 f a), Generic1 f) => Read (FunctorClassesDefault f a)Defined in transformers-compat-0.8 · Data.Functor.Classes.Generic.Internal(GShow (Rep1 f a), Generic1 f) => Show (FunctorClassesDefault f a)Defined in transformers-compat-0.8 · Data.Functor.Classes.Generic.Internal
Example
The most straightforward way to use the defaults in this module is to use
DerivingVia on GHC 8.6 or later. For example:
{-# LANGUAGE DeriveGeneric, DerivingVia #-}
import Data.Functor.Classes
import Data.Functor.Classes.Generic
import GHC.Generics
data Pair a = Pair a a
deriving stock Generic1
deriving (Eq1, Ord1, Read1, Show1)
via FunctorClassesDefault Pair
If using an older version of GHC, then one can also define instances manually. Here is an example:
{-# LANGUAGE DeriveGeneric #-}
import Data.Functor.Classes
import Data.Functor.Classes.Generic
import GHC.Generics
data Pair a = Pair a a deriving Generic1
instance C.Eq1 Pair where
C.liftEq = liftEqDefault
instance C.Ord1 Pair where
C.liftCompare = liftCompareDefault
instance C.Read1 Pair where
C.liftReadsPrec = liftReadsPrecDefault
instance C.Show1 Pair where
C.liftShowsPrec = liftShowsPrecDefault