[Haskell-cafe] [Haskell] Higher types in contexts
Henning Thielemann
lemming at henning-thielemann.de
Mon Mar 5 13:39:36 CET 2012
moved to haskell-cafe
On Mon, 5 Mar 2012, Barney Hilken wrote:
> Is there any deep reason why I can't write a polymorphic type in a context? I think the record update problem can be (sort of) solved if you could write:
>
> class Has r Rev (forall a. [a] -> [a]) => HRClass r where
> setHRClass :: (forall a.[a] -> [a]) -> r -> r
>
> but polymorphic types are not allowed in contexts. Is this one of the problems SPJ considers "Hard" or is it a feasible extension?
I don't know what you want to do, but you may wrap the (forall a. [a] ->
[a]) in an existential type:
data ListFunc = forall a. ListFunc ([a] -> [a])
class Has r Rev ListFunc => HRClass r where
setHRClass :: ListFunc -> r -> r
More information about the Haskell-Cafe
mailing list