[Haskell-cafe] FunDeps conflict
brianh at metamilk.com
Tue Jun 6 12:42:22 EDT 2006
Brian Hulley wrote:
> Joel Björnson wrote:
>> 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.
> The typeclass IsFoo is irrelevant to the fundep.
> The problem arises here:
> class Class2 a b | a -> b
> data Bar a = Bar a
> instance Class2 a a
> instance Class2 (Bar a) a
> because a and Bar a could be instantiated to two different types eg
> Bool and Bar Bool, yet the result type would be the same, but the
> fundep specifies that the 'a' type uniquely determines the 'b' type,
> hence the conflict.
Please ignore the above "explanation" cause it's wrong ;-)
I must have had an attack of fundep dyslexia and read the arrow the wrong
More information about the Haskell-Cafe