qualified instance declarations
Ralf Hinze
ralf at informatik.uni-bonn.de
Mon Jul 1 06:08:32 EDT 2002
Hi,
GHC (5.03.20020410) wrongly accepts the following:
::::::::::::::
C.lhs
::::::::::::::
> module C
> where
> class A a where
> a :: a -> Int
::::::::::::::
X.lhs
::::::::::::::
> module X
> where
> import qualified C
> instance C.A Int where
> C.a = id
Note that the class method is qualified on the LHS which is
not legal H98.
---
Incidentally, I also noticed that GHC and Hugs behave differently
for the following variant of X.lhs.
::::::::::::::
X.lhs
::::::::::::::
> module X
> where
> import qualified C
> instance C.A Int where
> a = const X.a
> a = 4
GHC happily accepts the file while Hugs complains that
ERROR "X.lhs":6 - Type error in instance member binding
*** Term : a
*** Type : a -> Integer
*** Does not match : Int -> Int
There seems to be a difference in defaulting. [Don't ask me
which is the correct behaviour.] The problem disappears if I
supply an explicit type signature for `a'.
Cheers, Ralf
More information about the Glasgow-haskell-bugs
mailing list