On 27-Sep-1999, Alex Ferguson <[EMAIL PROTECTED]> wrote:
> 
> Kevin Atkinson:
> > Yes but often putting things in type classes is tedious to do.  I also
> > want to be able to overload not only on the TYPE of parameters but also
> > on the NUMBER of parameters.  It IS possible to do these things and it
> > DOES make sense in a curing system.
> 
> That's far from clear.  Certainly, I don't think it's likely to be
> reasonably possible a conversative extension.

I think it could be.
However, whether it is in "the spirit of Haskell" is another question.

Mercury supports both type classes and ad-hoc overloading.
You can define two different symbols with the same name in
different modules and import them into another module
and the compiler will use your type declarations to disambiguate.
You can define the same symbol with different arities (number of parameters)
within a single module, and the compiler will use the types and the
context to disambiguate.

Ad-hoc overloading and type inference don't mix so well, because
you can easily get ambiguities which the compiler cannot resolve.
However, the user can add explicit type annotations where necessary
to resolve the ambiguities.  And I find this preferable to making
the explicit type annotations part of the symbol names, which is
what I currently tend to do when writing Haskell.

(Note that the Mercury compiler currently does not do nearly as good
a job of dealing with type inference in the presense of ambiguities
as it could do.)

> > > > 2) Support for TRUE OO style programming.
> 
> > No. I mean being able to do things such as.
> > 
> > Have a collection of object of a common base class AND be able to up
> > cast them when necessary.
> 
> If I understand you correctly, then the best way of doing this would be
> with existentially (boundedly) quantified data types, currently a
> non-standard extention present in hbc (and I think, ghc, these days, not
> sure if it's with the same generality.)

ghc does not offer any facility for type class casts.
As far as I'm aware, hbc doesn't either, but I don't know for sure.

-- 
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.



Reply via email to