[Haskell-cafe] FunDeps conflict

Joel Björnson bjornson at dtek.chalmers.se
Tue Jun 6 05:38:40 EDT 2006

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 ?


More information about the Haskell-Cafe mailing list