first-class polymorphism beats rank-2 polymorphism

Ashley Yakeley ashley@semantic.org
Wed, 6 Mar 2002 16:03:49 -0800


At 2002-03-06 06:13, Ralf Laemmel wrote:

>This is not a bug, 

Isn't it? Consider:

  class Class x where
   combinator' :: (forall y. Class y => y -> y) -> x -> x

This gives:

  combinator' :: forall x. Class x => (forall y. Class y => y -> y) -> x 
-> x

What happens when you pass something of type (forall y. Class y => y -> 
y)?

  s :: forall x. Class x => x -> x
  s = combinator' id;

So I would claim that these two types are the same:

  forall x. Class x => (forall y. Class y => y -> y) -> x -> x
  (forall y. Class y => y -> y) -> (forall x. Class x => x -> x)

...so you should be able to do this:

  combinator :: (forall y. Class y => y -> y) -> (forall x. Class x => x 
-> x)
  combinator f x = combinator' f x

but for some reason GHC 5.02.2 complains. I think this is a bug. 
Apparently 5.03 has rank-N polymorphism so maybe this is fixed too.

-- 
Ashley Yakeley, Seattle WA