replib
replib copied to clipboard
Add suport for existentials to RepLib
Right now we cannot represent any datatype that has an existential component.
For example:
data Ex = forall a. MkT a
or
data ExR = forall a. Rep a => MkT a
or perhaps even:
data ExR1 c = forall a. Rep1 c a => MkT a
The former type is a bit useless for generic programming---there is no runtime
component for the hidden type. However, it may be useful to add some support
for the latter two types. This support would allow us to include some
structural information for the R type.
The way to do it is to define a protypical Existential datatype
data ExR f = forall a. Rep a => ExR (f a)
and then add a data constructor for this type to R
RExR :: (forall a. Rep a => Rep (f a)) -> R (ExR f)
and to R1
RExR1 :: (forall a. Rep a => ctx (f a)) -> R1 ctx (ExR f)
arbitrary datatype that include existentials can use this + Data + newtype
tricks to form their representation. (I'm not sure how useful RExR1 would be.
Might be fun to play with though.)
Original issue reported on code.google.com by stephanie.weirich on 2 Dec 2010 at 8:44