[Haskell-beginners] polymorphism vs. overloading

Dennis Raddle dennis.raddle at gmail.com
Fri Dec 17 04:34:52 CET 2010


I looked up the difference between polymorphism and overloading (speaking of
all languages in general), and apparently polymorphism is a general term for
an operation that can accept arguments of different types. Overloading is a
form of "ad-hoc polymorphism" in which the compiler chooses specific code to
be executed by inspecting the arguments at compile time. Apparently "true
polymorphism" means exactly the same code is executed no matter what the
argument types, such as implemented by inheritance in C++ (*) Now my
understanding of Haskell's classes is that the compiler chooses the right
instance of the class at compile time. Does that mean that Haskell
implements only ad-hoc polymorphism?


(*) Another question: if someone says "What feature of C++ makes
polymorphism possible?" What is the correct answer? Inheritance? Virtual
methods? Some combination?

-D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20101216/984adde9/attachment.htm>


More information about the Beginners mailing list