qualified instance declarations
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 ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: qualified instance declarations
For those puzzled by the number of things called 'a' in Ralf's program, I'm attaching an alpha-renamed version. Removing the type signature (or changing the type signature to Integer) for a results in Ralf's type error in Hugs. It does indeed look as though Hugs applies defaulting to 'a' and comes up with the type Integer. Off the top of my head, I'd say this was correct since the default default is (Integer,Double). -- Alastair Reid module C where class B a where f :: a - Int module X where import qualified C instance C.B Int where f = const X.a a :: Int a = 4 ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: qualified instance declarations
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 This has been fixed, and GHC 5.04 will behave correctly. 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'. Hugs's defaulting behaviour differs from Haskell 98 (and always has done). See for example this discussion on the Haskell mailing list: http://www.haskell.org/pipermail/haskell/2002-May/009616.html (plus other messages with the same subject). Could someone from the Hugs camp please document this? Cheers, Simon ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs