[Haskell-cafe] Moving "forall" over type constructors

Klaus Ostermann ko at daimi.au.dk
Mon Jun 9 09:55:20 EDT 2008

> But here we have an argument that can return a Wrapper (t a) for any
> 'a'; that does *not* mean it can return a wrapper of a polymorphic type.
> If you think about 'a' as an actual argument, then you could pass 'Int'
> to get a Wrapper (t Int), Bool to get a wrapper (t Bool), or even
> (forall a. a -> a) to get a Wrapper (t (forall a. a -> a)), but no
> argument at all could make a Wrapper (forall a. t a).

I just found out that it *is* possible to implement the inside function,
namely as follows:

> inside :: forall t. ((forall a. Wrapper (t a))-> Wrapper (forall a. (t
> a)))
> inside x = Wrapper f
>   where f :: forall a. (t a)
>         f = unwrap x
>         unwrap (Wrapper z) = z

I guess this solves my problem. Sorry for bothering you with this question.
I still find it a bit weird to write all these obfuscated identity functions
to make the type checker happy, though.


View this message in context: http://www.nabble.com/Moving-%22forall%22-over-type-constructors-tp17732668p17733353.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list