scoping of type variables in class instances
The scoping of type variables in class instances is underspecified. GHC scopes them for the entire instance, Hugs does not.
GHC's approach is more expressive, it is sometimes needed - especially in combination with multi-parameter classes. Example:
class Ping a b where ping:: a->b
newtype A a = A a
instance (Show b,Ping a b) => Show (A a) where
show (A x) = show (ping x)
This is ambiguous and thus rejected, but we could resolve the ambiguity by annotating 'ping' with its expected type a->b, but that only works if the scoping of the class instance extends to the member definition.
pros
: extends expressiveness, implemented in GHC anyway, was underspecified in Haskell anyway
cons
: very minor: it could break some existing programs as it makes some local functions non-polymorphic, though these would have been badly written
See also: http://hackage.haskell.org/trac/haskell-prime/wiki/ScopedTypeVariables
Trac metadata
Trac field | Value |
---|---|
Version | |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Proposal |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |