On 04/01/2014 2:27 PM, Jonathan S. Shapiro wrote:
On Sat, Jan 4, 2014 at 7:01 AM, Sandro Magi <[email protected]
<mailto:[email protected]>> wrote:
On 03/01/2014 8:40 PM, Jonathan S. Shapiro wrote:
Basically, Interfaces are the mechanism for existential
quantification.
interfaces = existential quantification + overloading
I am not sure how overloading gets in to this.
You're probably assuming a more liberal definition of "overloading", like that found in C# and Java where one can specify overloaded functions of different arities. I intended the more principled version as implied by type classes, where overloading is simply defining a type-indexed operation. We can disregard this if that's the case since it will only cause confusion.
interfaces = existential quantification + single parameter type classes I said that a while back, but I no longer think that is correct.An interface is existentially quantified over 'this exactly if it has non-static methods. An interface may be parametric. Type variables /other than/ 'this are universally quantified. Those universally quantified variables can be subject to constraints.Because those type variables are universally quantified, I think that interfaces subsume multi-parameter type classes as well.
The following are equivalent in my mind:
public interface IFoo
{
T0 Foo<T0, T1>(T0 arg0, T1 arg1)
where T0 : IFoo;
}
class Foo x where
foo :: Foo a => x -> a -> b -> a
-- existential wrapper
data AnyFoo = forall a. Foo a => AnyFoo a
-- instance for the existential
instance Foo AnyFoo where
foo (AnyFoo x) a b = foo x a b
The 'a' and 'b' parameters of the overloaded foo function are also
universally quantified, and 'a' has an additional IFoo constraint. Am I
missing something?
Finally, for interfaces to subsume multiparam type classes, they must dispatch on multiple parameter types ala multimethods, which interfaces don't do unless you're assuming some sort of generalized interface like from the papers I posted a month or two ago.
Sandro
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
