
16 Jun
2011
16 Jun
'11
3:07 a.m.
| 1. mutual dependencies: | class Add x y z | x y -> z, x z -> y, y z -> x | I think this example can be emulated with type functions; the | emulation didn't work with GHC 6.10, at least. It may work now.
(The example you give is a bit odd because you specified that the types of any two arguments determine the third, which probably isn't what you want for Add. But no matter.)
Actually I meant the triple dependencies, when any two arguments determine the third. That class was implemented in the following http://okmij.org/ftp/Haskell/PeanoArithm.lhs (it was called Sum). The file also demonstrates exponentiation, as a ternary relation where any two arguments determine the third. (Unlike Sum, that relation is partial).