qualified instance declarations
Simon Marlow
simonmar at microsoft.com
Mon Jul 1 07:42:03 EDT 2002
> 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
More information about the Glasgow-haskell-bugs
mailing list