qualified instance declarations
Simon Marlow
simonmar@microsoft.com
Mon, 1 Jul 2002 12:42:03 +0100
> GHC (5.03.20020410) wrongly accepts the following:
>=20
> ::::::::::::::
> C.lhs
> ::::::::::::::
> > module C
> > where
>=20
> > class A a where
> > a :: a -> Int
> ::::::::::::::
> X.lhs
> ::::::::::::::
> > module X
> > where
> > import qualified C
>=20
> > instance C.A Int where
> > C.a =3D 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.
>=20
> ::::::::::::::
> X.lhs
> ::::::::::::::
> > module X
> > where
> > import qualified C
>=20
> > instance C.A Int where
> > a =3D const X.a
>=20
> > a =3D 4
>=20
> GHC happily accepts the file while Hugs complains that
>=20
> ERROR "X.lhs":6 - Type error in instance member binding
> *** Term : a
> *** Type : a -> Integer
> *** Does not match : Int -> Int
>=20
> 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