TypeFamilies vs. FunctionalDependencies & type-level recursion

oleg at okmij.org oleg at okmij.org
Thu Jun 16 09:07:02 CEST 2011



> |   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).





More information about the Haskell-prime mailing list