Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A convenience class for retrieving the first field of any constructor in a datatype.
The primary usage for this class is generic derivation:
data D a = D a () String deriving Generic instance FirstParameter (D a) a
Note that _the deriver does not check you are requesting a valid/safe instance._ Invalid instances propagate the error to runtime. Fixing this requires a lot more type-level work. (The generic-lens library has a general solution, but it's slow and memory-consuming.)
Documentation
class FirstParameter a e | a -> e where Source #
Nothing
getFirstParameter :: a -> e Source #
default getFirstParameter :: (Generic a, GFirstParameter (Rep a) e) => a -> e Source #
setFirstParameter :: e -> a -> a Source #
default setFirstParameter :: (Generic a, GFirstParameter (Rep a) e) => e -> a -> a Source #
Instances
class GFirstParameter f e where Source #
getFirstParameter' :: f a -> e Source #
setFirstParameter' :: e -> f a -> f a Source #