overlapping instances and functional dependencies

C T McBride c.t.mcbride@durham.ac.uk
Thu, 21 Aug 2003 13:58:18 +0100 (BST)


Hi all

With overlapping instances, I'm allowed

  class OK x y

  instance Functor f => OK (f x) (f y)

  instance Functor f => OK x (f y)

but I'm not allowed

  class Bad x y z | x y -> z

  instance Functor f => Bad (f x) (f y) Bool

  instance Functor f => Bad x (f y) Int

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?

Cheers

Conor

PS a more complicated, less contrived example is available on request