2 ms·
> What are typeclasses if not inheritance? Overloading not inheritance. It is closer to the notion of interfaces in traditional OO languages, but it's a mistak
by naasking 9y ago
> What are typeclasses if not inheritance?
Overloading not inheritance. It is closer to the notion of interfaces in traditional OO languages, but it's a mistake to confuse interface implementation as inheritance.
This is a common problem with traditional OO languages: they conflate inheritance with subtyping, ie. "Y inherits the behaviour of X" is not always the same as "Y can be used anywhere an X can be used" (subtyping). C++ has "private inheritance" to separate these notions now, but it's a kludge from this initial design mistake.
So type classes use subtyping, but not inheritance. Interface implementation is also closer to subtyping than inheritance.