overlapping instances and functional dependencies
Simon Peyton-Jones
simonpj@microsoft.com
Thu, 21 Aug 2003 14:09:34 +0100
| With overlapping instances, I'm allowed
|=20
| class OK x y
|=20
| instance Functor f =3D> OK (f x) (f y)
|=20
| instance Functor f =3D> OK x (f y)
|=20
| but I'm not allowed
|=20
| class Bad x y z | x y -> z
|=20
| instance Functor f =3D> Bad (f x) (f y) Bool
|=20
| instance Functor f =3D> Bad x (f y) Int
|=20
| I don't quite see why. Naively, I imagine that if the OK instances are
| effectively prioritized, then Bad's rules for computing z from x and y
| could be similarly prioritized. Can anyone explain why this naive
| imagining is incorrect?
I don't think anyone has really worked through the interaction of
overlapping instances (already swampy) with functional dependencies.
What you say makes sense, but it's not what GHC or Hugs implement.
Maybe they should
Simon