[Haskell-cafe] Scope of type variables in associated types

Matthew Sackman matthew at wellquite.org
Sat May 19 15:40:46 EDT 2007


The following doesn't seem to work. Is this a limitation of the current
implementation or will it never work? Are there any work arounds without
introducing extra type params into the data type E?

> class G a b | a -> b where
>     data E a :: *
>     wrap :: b -> E a
>     unwrap :: E a -> b

> instance G a b where
>     data E a = EC b -- this line - the b is not in scope.
>     wrap = EC
>     unwrap (EC b) = b

I get "Not in scope: type variable `b'". I was rather hoping it would be
in scope. I've tried:

> instance forall a b . G a b where
> ...

but that doesn't seem to extend the scope as it does with functions. I
realise this is bleeding edge stuff. But I can't seem to work out
from the various wiki pages on this whether this is going to be
eventually supported. This is all with today's GHC HEAD.

Cheers,

Matthew
-- 
Matthew Sackman
http://www.wellquite.org/


More information about the Haskell-Cafe mailing list