Resent due to local problems at Glasgow.
Kevin
Date: Tue, 15 Sep 1992 11:08:35 -0400
From: [EMAIL PROTECTED] (Martin Odersky)
To: [EMAIL PROTECTED]
David Barton asks:
>> (ft :: Function b c, gt :: Function a b) => ft -> gt -> a -> c.
>> [Aside: This is another example where multiple argument type classes
>> lead to ambiguities, but parametric type classes don't.]
> Pardon a dumb question, but could I request a clarification here? Is
> the equivalent multiple argument type class definition ambiguous?
It is. A generic definition of ambiguity is: A polymorphic type
C => T
is ambiguous if there is a type variable constrained by C that does
not appear in T.
Now, using multiple argument classes, the type of (.) would be written
(Function ft b c, Function gt a b) => ft -> gt -> a -> c.
This is ambiguous because 'b' appears in the context but not in the
type.
If we use parametric type classes, however, 'b' would be a parameter
to type class 'Function' rather than being constrained by it. Hence,
no ambiguity.
I should note that there is another extension of Haskell's type class
concept, called "constructor classes" that can also type the example
above without ambiguities. Maybe Mark Jones can write a bit more
about that.
- -- Martin Odersky