
Brian,
Also, the rule would not be quite as simple as you make it out to be, since
forall a. (forall b. Foo a b => a -> b) -> Int
is a legal type, for example.
Is it? GHCi gives me an error if I try typing a function like that.
{-# OPTIONS -fglasgow-exts #-} class Foo a b
f :: forall a. (forall b. Foo a b => a -> b) -> Int f = undefined
No instance for (Foo a b) arising from instantiating a type signature at x.hs:5:4-12 Probable fix: add (Foo a b) to the type signature(s) for `f' Expected type: (forall b1. (Foo a b1) => a -> b1) -> Int Inferred type: (a -> b) -> Int In the definition of `f': f = undefined
Short answer: forall a. a -> a cannot be instantiated to the type of f. Try: {-# OPTIONS -fglasgow-exts #-} class Foo a b f :: forall a. (forall b. Foo a b => a -> b) -> Int f _ = undefined Now, you should be fine. HTH, Stefan