Hi, On 20-May-2005, Conal Elliott <conal@conal.net> wrote:
The program below fails to compile under ghc 6.4, giving the following error message:
c:/conal/Eros/Haskell/PTest.hs:13:0: Illegal instance declaration for `Path (PCompose po pi) a a' whole whole'' (the instance types do not agree with the functional dependencies of the class) In the instance declaration for `Path (PCompose po pi) a a' whole whole'' Failed, modules loaded: none.
I'm stumped. Can anyone explain how this instance violates the functional dependencies?
The problem is that whole' can't be determined from po, pi, a, a' and whole, therefore the first functional dependency is not met. The two constraints on the instance and the two functional dependencies on the class induce the following four dependencies between the type variables in the instance: pi a a' mid -> mid' pi mid mid' -> a a' po mid mid' whole -> whole' po whole whole' -> mid mid' None of these rules can fire given po, pi, a, a' and whole, which means that no other variables are determined from them. Cheers, Mark.