Posts

Showing posts with the label functional-dependencies

Haskell Functional Dependencies Consistency Condition: is it needed? Is it used?

Haskell Functional Dependencies Consistency Condition: is it needed? Is it used? The FunDep Consistency Condition appears in all the literature dating back to Mark P Jones 2000 paper. And it's inherited from the database-theory origins of FunDeps. But Haskell's FunDeps are not very much like in databases: a FunDep -> means: in any instance for this class, I promise to give an algorithm to get from the class parameters on the left to those on the right. (In the instance decl, that algorithm might have to go via its constraints -- then you need UndecidableInstances .) -> UndecidableInstances It's reasonably well-known that GHC's implementation of the Consistency Condition is bogus -- see this answer, for example. And that's a Good Thing so that I can write class TypeEq a a' (b :: Bool) | a a' -> b where ... instance TypeEq a a True where ... instance (b ~ False) => TypeEq a a' b where ... (That needs OverlappingInstances or pragmas, as wel...