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 SecondParameter (D 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 SecondParameter a e | a -> e where Source #
Nothing
getSecondParameter :: a -> e Source #
default getSecondParameter :: (Generic a, GSecondParameter (Rep a) e) => a -> e Source #
setSecondParameter :: e -> a -> a Source #
default setSecondParameter :: (Generic a, GSecondParameter (Rep a) e) => e -> a -> a Source #