[Haskell-cafe] Re: ANNOUNCE: GHC survey results
waldmann at imn.htwk-leipzig.de
Tue Jun 28 13:29:49 EDT 2005
Bulat Ziganshin wrote:
> JW> interface Figure
> JW> class Circle implements Figure
> JW> class Box implements Figure
> this don't give ability to create polymorphic collections
You mean in Haskell? I would probably use existential types then.
Something like data EFigure = forall f . Figure f => EFigure f
and - as Georg Martius once pointed out -
with an additional "instance Figure EFigure ..."
to avoid at least some of the (un)boxing code.
As a whole, this *does* look messy - Java programmers can nicely write
the name of the interface when they mean some unspecified instance:
Figure f = new Circle () ...
Of course that's only so because their interfaces (type classes)
are always unary predicates. I definitely would not give up multi
parameter type classes from Haskell. But still the Java notation
looks neat and concise.
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------
More information about the Haskell-Cafe