overlapping instances and functional dependencies

Wolfgang Jeltsch wolfgang@jeltsch.net
Sat, 9 Aug 2003 01:32:49 +0200


Hello,

I have this code:
    class C a b c | a b -> c where
        f :: a -> b -> c

    instance C a b c => C a (x,y,b) c where
        f a (_,_,b) = f a b

    instance C a (a,c,b) c where
        f _ (_,c,_) = c
ghci -fglasgow-exts -fallow-overlapping-instances compiles it without 
complaint but hugs -98 +o says:
    ERROR "ClassProblem.hs":7 - Instances are not consistent with dependencies
    *** This instance    : C a (a,b,c) b
    *** Conflicts with   : C a (b,c,d) e
    *** For class        : C a b c
    *** Under dependency : a b -> c
Can anyone tell me what the reason for this is and, maybe, how to avoid these 
problems with Hugs?

Wolfgang