Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Language.Fortran.Util.FirstParameter
Description
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 #
Minimal complete definition
Nothing
Methods
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 :: k -> Type) e where Source #
Methods
getFirstParameter' :: forall (a :: k). f a -> e Source #
setFirstParameter' :: forall (a :: k). e -> f a -> f a Source #