[Haskell-cafe] Object oriented haskell.

Richard A. O'Keefe ok at cs.otago.ac.nz
Fri May 16 05:43:16 UTC 2014


On 16/05/2014, at 9:37 AM, silvio wrote:

>> In what languages is (.) cool, and in what way?
> 
> Because depending on what is before it, what is behind it can have
> different meanings.

That's not cool, that's majorly problematic.

Ad hoc polymorphism is not good for readability.

> For me this is one of the main points. I just don't
> like the name collision problem in Haskell. Take something like size for
> instance it is pretty clear what it means yet unless you have a type
> class that everybody knows about you can use it on only one thing.

For the person WRITING the code, this is a pain in the backside.
For the person READING the code, it is great blessing.

In Java, foo.size() could literally do ANYTHING.
In Smalltalk, "x value" might be simply extracting a slot from
an object or it might be invoking an arbitrarily complex operation
with arbitrary side effects or (in at least one Smalltalk) it might
be a special kind of synchronisation, and it's not hard to end up
in situations where all three are in play.

Note that the dot as such actually plays no significant role in
OO.  Common Lisp and Ada both can do dynamic dispatch using ordinary
function call syntax.  Indeed, Common Lisp shows an pretty horrible
and not very principled restriction in the dotty view of the world:
the dynamic call (draw Picture Canvas) can dispatch on Picture, or
Canvas, or both, depending on what best suits your problem, whereas
picture.Draw(canvas) can only dispatch on picture.




More information about the Haskell-Cafe mailing list