incompatible signatur syntax within instance definition

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Dec 9 19:32:04 EST 2003


On 08-Dec-2003, Christian Maeder <maeder at tzi.de> wrote:
> Fergus Henderson wrote:
> >I think the issue here is that in ghc (with -fglasgow-exts),
> >the "a" here refers to the same type variable "a" in the
> >top of the instance declaration, which has already been
> >constained, and cannot be constrained again.
> 
> Is that a bug or a feature?

A feature.  It's called "scoped type variables".  See
<http://www.haskell.org/ghc/docs/6.2/html/users_guide/type-extensions.html#SCOPED-TYPE-VARIABLES>:
"The type variables in the head of a class or instance declaration scope
over the methods defined in the where part.".

Or were you referring to the fact that variables which are already
constrained can't be constrained again?  IMHO that is a feature too.
It doesn't make sense to constrain a variable at any point other than
the point where that variable is introduced.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


More information about the Glasgow-haskell-users mailing list