scoped type variables in instance?

Jay Cox sqrtofone at yahoo.com
Mon Apr 15 21:18:59 EDT 2002


On Mon, 15 Apr 2002, Ross Paterson wrote:

> GHC (even without -fglasgow-exts) rejects the following:
>
> 	newtype Foo a = Foo a
>
> 	instance Eq a => Eq (Foo a) where
> 		Foo x == Foo y = bar
> 			where   bar :: a
> 				bar = undefined
>
> It seems to treat the inner a as bound to the a in the instance header,
> and thus not universally quantified.


class Eq z  where
  (==) :: z -> z -> Bool
                    ^^^^

It's complaining that the type is less polymorphic than expected, no?

I think you must be thinking of another example that irks you.

BTW, whats wrong with refering to a instanced type variable in a instance
definition?  I would think it allows for more powerful expression.

Jay Cox





More information about the Glasgow-haskell-bugs mailing list