On 04-Nov-1999, Christopher Jeris <[EMAIL PROTECTED]> wrote:
> On Thu, 4 Nov 1999, Peter Ross wrote:
> > Existential types tend to be most useful when combined with
> > typeclasses. This is because you don't know what type is being
> > returned, however you do know an interface which can be used with this
> > type.
>
> So this is a way to dodge the concrete-type-dependent destructuring that
> so often arises in ML, Haskell, other "sum-type-centric" languages?
No, that's a separate issue.
> How does this solution compare to something like views, as in Okasaki's
> proposal for SML (http://www.cs.columbia.edu/~cdo/ml98views.dvi) ?
Views address a different problem.
Views allow you to access an abstract data type using the same
syntax that you would use if it were a concrete data type.
They are essentially just syntactic sugar.
Views don't address the issue of multiple implementations of
the same interface at all.
Type classes let you have multiple implementations of the
same interface, and pass a arbitrary instance of this interface downwards.
Existential types let you *return* an arbitrary instance of an interface.
I see this as pretty fundamental.
Pascal allowed you to pass down function parameters, but there was no way to
return them. Modern functional languages do let you not only pass down
function parameters, but also to return them. This is often very useful.
Likewise, the ability to return an arbitrary instance of an interface
is often very useful too.
Sure, you can often use lazy evaluation as a work-around, if you're lacking
that fundamental capability. But for anything but the simplest cases,
that work-around becomes pretty ugly, and in some cases it's really not
possible at all.
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.