Bug in context reduction with overlapping instances
John Hughes
john.hughes@swipnet.se
Tue, 18 Dec 2001 06:21:08 +0100
Here's a small program defining a collection class:
------------------
class Sat a where=20
dict :: a
data EqD a =3D EqD {eq :: a->a->Bool}
instance Sat (EqD a) =3D> Eq a where
(=3D=3D) =3D eq dict
class Collection c cxt | c -> cxt where
empty :: Sat (cxt a) =3D> c a
single :: Sat (cxt a) =3D> a -> c a
union :: Sat (cxt a) =3D> c a -> c a -> c a
member :: Sat (cxt a) =3D> a -> c a -> Bool
instance Collection [] EqD where
empty =3D []
single x =3D [x]
union =3D (++)
member =3D elem
------------------
Loading this program with overlapping instances turned on produces the =
error message:
Type checking
ERROR "C:\windows\Skrivbord\HugsBug.hs":24 - Cannot justify constraints =
in instance member binding
*** Expression : member
*** Type : (Collection [] EqD, Sat (EqD a)) =3D> a -> [a] -> =
Bool
*** Given context : (Collection [] EqD, Sat (EqD a))
*** Constraints : Eq a
Very strange, given the instance declaration
instance Sat (EqD a) =3D> Eq a
The behaviour is the same in the February and December 2001 versions.
John Hughes