
6 Jun
2006
6 Jun
'06
5:38 a.m.
Hi. I have a question regarding type classes and FunDeps. Consider the following code :
class Class2 a b | a -> b
class IsFoo a data Bar a = Bar a
instance IsFoo a => Class2 a a instance IsFoo a => Class2 (Bar a) a
The last two instantiations will yield a 'Functional dependencies conflict error'. From what I understand, this is because (Bar a) *MAY* instantiate the type class isFoo, which would obviously lead to a conflict between the two instantiations. Is there anyway to get around this, knowing that (Bar a) won`t instantiate the isFoo class, or is the right answer simply to get rid of the FunDep ? Thanks /Joel