[Haskell-cafe] Re: Rank-2-polymorphism problem

Martin Huschenbett huschi at gmx.org
Fri Mar 23 16:37:16 EDT 2007


Ian Lynagh schrieb:

> readValue' :: Field -> Maybe (forall s. SqlBind s => s) -> Value
> readValue' fld s =
>     if isJust s then readValue fld (fromJust s) else emptyValue fld

Thank you very much, that's exactly what I wanted. After reading in the 
GHC users guide about rank 2 polymorphism I thought that this is not 
possible. Chapter "7.4.8. Arbitrary-rank polymorphism" says:


There is one place you cannot put a forall: you cannot instantiate a 
type variable with a forall-type. So you cannot make a forall-type the 
argument of a type constructor. So these types are illegal:

     x1 :: [forall a. a->a]
     x2 :: (forall a. a->a, Int)
     x3 :: Maybe (forall a. a->a)


Maybe the users guide is not precise enough at this point.

Regards, Martin.



More information about the Haskell-Cafe mailing list