A question concerning functional dependencies

Dylan Thurston dpt@math.harvard.edu
Mon, 2 Sep 2002 10:47:57 -0400


--oTHb8nViIGeoXxdp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Sep 02, 2002 at 03:11:58AM -0700, Ashley Yakeley wrote:
> At 2002-09-02 02:46, Jerzy Karczmarczuk wrote:
>=20
> >class Module v s | v->s  .
> ...
> >instance Num s =3D> Module (v->s) s=20
> ...
> >instance ...=3D> Module ((v->s)->(v->s)) s
> ...
> >But GHCi yells that two instances in view of the functional=20
> >dependency declared are in conflict.
>=20
> GHCi is correct. Bear in mind GHC ignores contexts in instance=20
> declarations when calculating conflicts. This is unfortunate, but=20
> apparently fixing it would be hard.

Even taking contexts into account, these two might still conflict: if
you had

instance Num ((v->s)->v)

for some values of v and s, you would get a conflict.

GHC (and Hugs) check for potential conflicts like this unless you
explicitly allow overlapping instances.

--Dylan

--oTHb8nViIGeoXxdp
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9c3odVeybfhaa3tcRAt6+AKCRZQRpmNsKAOd8qGZmxTgYmisOYwCfcRL4
OaiLila9E4zctABfyfho0ks=
=tL3T
-----END PGP SIGNATURE-----

--oTHb8nViIGeoXxdp--