3 ms·
I may be way off on this, but I like to think of them as a bridge between ad-hoc and parametric polymorphism. Or maybe an ad hoc wolf in parametric sheep's clot
by mumblemumble 5y ago
I may be way off on this, but I like to think of them as a bridge between ad-hoc and parametric polymorphism. Or maybe an ad hoc wolf in parametric sheep's clothing.
Functions and types that refer to typeclasses are parametrically polymorphic insofar as they don't refer to a specific implementation of that type. This is quite different from run-of-the-mill function overloading, where you must supply separate implementations for every set of types you want to support.
But, unlike how parametric polymorphism works in OOP, late binding is not an option. At the use site, the typeclass implementation you want to use must be statically resolvable. In that respect, it does behave like function overloading.