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

Martin Huschenbett huschi at gmx.org
Fri Mar 23 19:27:24 EDT 2007

Hi again,

the solutions/proposals of Ian and Iavor seem to be exactly what I need 
at a first glance. But looking at them more in detail reveals some other 

I also have got a function

 > getFieldValueMB :: SqlBind s => Statement -> String -> Maybe s

To get Ians approach working I would need a function of type

 > getFieldValueMB' :: Statement -> String -> Maybe (forall s. SqlBind s 
=> s)

and for Iavor approach I would need a function of type:

 > getFieldValueMB' :: Statament -> String -> Maybe Binder

which are almost the same. The remaining problem is: How can I construct 
either of these functions?

My thoughts were that for any class C the types

 > Maybe (forall a. C a => a)  (I will call it T1 for short)


 > (forall a. C a => Maybe a)  (I will call it T2 for short)

are isomorphic. Defining the isomorphism from T1 to T2 is quite simple:

iso1 :: Maybe (forall a. C a => a) -> (forall a. C a => Maybe a)
iso1 (Just s) = Just s
iso1 Nothing  = Nothing

But I don't catch how to define the isomorphism of the other direction 
(from T2 to T1). I would guess that defining this isomorphism would also 
solve my problem concerning the SQL stuff.

So, is there anybody who knows how to define this isomorphism in a way 
that GHC-6.6 can compile it?

Thanks for you help in advance,


More information about the Haskell-Cafe mailing list