
continuing the list of odd cases in type class handling, here is a small example where overlap resolution is not taken into account when looking at FDs. context: both hugs and ghc resolve instance overlaps in favour of the most specific declaration. so the following works in both ghc (darcs, 25022006) and hugs (minhugs 20051031): {- both ghc and hugs accept without 3rd par and FD neither accepts with 3rd par and FD -} data T = T deriving Show data F = F deriving Show class TEQ a b {- tBool | a b -> tBool -} where teq :: a -> b -> Bool instance TEQ a a {- T -} where teq _ _ = True instance TEQ a b {- F -} where teq _ _ = False test = print (teq True 'c', teq True False) and both print "(False,True)", so best-fit overlap resolution entirely determines which instance to choose! now, if we uncomment the third class parameter, they both complain (as expected, though about different things). however, if we also uncomment the functional dependency, to fix the ambiguity wrt the 3rd parameter, both complain that this FD is in conflict/inconsistent with the instances! as far as i understand it, the potential inconsistency should have been eliminated by the best-fit overlap resolution, so I submit this is a bug (and unlike the earlier example I submitted to hugs-bugs, this fails with both hugs and ghc; and it is less open to alternative interpretations, I hope). cheers, claus