Why does this violate the “Coverage Condition”,

Reading about UndecidableInstancesI understand that my problem in this question is equivalent:

class Convert a b | a -> b where
     convert :: a -> b

instance Convert a b => Convert [a] [b] where
     convert = map convert

I understand why "UndecidableInstance" is necessary and (kind of), why a type controller can loop in a specific case. However, I still do not understand how this violates the “Coverage Status”. I mean when I read the definition

For each functional dependence tvsleft -> tvsrighton the class, each variable of type S(tvsright)b should appear in S(tvsleft), where Sis a wildcard mapping of each type of the variable in the class declaration to the corresponding type in the instance declaration.

The previous example seems to satisfy this definition. I know that this is not the case, but I cannot understand why (I probably do not understand this).

+4
source share
1 answer

I suppose I thought it tvslefthad something to do with the part to the left of =>the instance. But, having read more carefully, I see that this is not so. At least for this example, this restriction is only for the head of the instance.

For a class with a head Convert a band functional dependence, a -> bwe have

tvsleft = a
tvsright = b

For an instance, we must then replace the variables in the head class Convert a bto get the instance title by Convert [a] [b]specifying

S(tvsleft) = S(a) = [a]
S(tvsright) = S(b) = [b]

and a type variable bin [b]does not occur in [a].

+3

All Articles