[Haskell-cafe] Is it possible to represent such polymorphism?

Andrew Coppin andrewcoppin at btinternet.com
Sun Oct 2 22:26:30 CEST 2011

On 02/10/2011 07:15 PM, Du Xi wrote:

> I guess this is what I want, thank you all. Although I still wonder why 
> something so simple in C++ is actually more verbose and requires less 
> known features in Haskell...What was the design intent to disallow 
> simple overloading?

In C++, the code is inferred from the types. (I.e., if a function is
overloaded, the correct implementation is selected depending on the
types of the arguments.)

In Haskell, the types are inferred from the code. (Which is why type
signatures are optional.)

Really, it's just approaching the same problem from a different direction.

Also, as others have said, you're probably just approaching the problem
from the wrong angle. You don't design an object-oriented program the
same way you'd design a procedural program; if you do, you end up with a
horrible design. Similarly, you don't design a functional program the
same way you would design an object-oriented one. It takes time (and
experience) to figure out how to approach FP - or any other radically
different paradigm, I suppose...

More information about the Haskell-Cafe mailing list