Consider Haskell's Generic
class :
class Generic a where
-- | Generic representation type
type Rep a :: * -> *
-- | Convert from the datatype to its representation
from :: a -> (Rep a) x
-- | Convert from the representation to the datatype
to :: (Rep a) x -> a
I'm curious as to why it wasn't written as below:
class Generic a where
-- | Generic representation type
type Rep a :: *
-- | Convert from the datatype to its representation
from :: a -> Rep a
-- | Convert from the representation to the datatype
to :: Rep a -> a
More specifically what does the type variable x
stand for in the standard definition?
This is done to allow the Generic
and Generic1
classes to share most of their representation types. Whether this was really a good idea is debatable. Just do your best to ignore the extra parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With