If f2 is legal, why if f3 illegal? For some usage site of f3, the
constraint C String b might allow b to be resolved given whatever
instances of C are in effect.

Is there a motivation for these behaviors?

Are these sorts of cases discussed in the CHR/FD paper that motivated
the coverage condition (which I have yet to read)?

It should be possible to resolve the constraints from the types in the signature. That rules out f1 and f3.

For f2, given a type for a, say Int, not just any odd instance for b will do, say

        instance C Int Bool

GHC says:

    No instance for (C Int b)
      arising from use of `f2' at Q.hs:30:6-9
    Possible fix: add an instance declaration for (C Int b)
    In the expression: f2 x
    In the definition of `f': f x = f2 x

No, it has to be an instance for all possible types b:

        instance C Int b

So, you can only call f2 with types a for which the instance C a b is completely independent of b. There is no ambiguity.

Tom

--
Tom Schrijvers

Department of Computer Science
K.U. Leuven
Celestijnenlaan 200A
B-3001 Heverlee
Belgium

tel: +32 16 327544
e-mail: [EMAIL PROTECTED]
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to