https://wiki.haskell.org/Polymorphism says
Ad-hoc polymorphism refers to when a value is able to adopt any one of several types because it, or a value it uses, has been given a separate definition for each of those types. For example, the + operator essentially does something entirely different when applied to floating-point values as compared to when applied to integers – in Python it can even be applied to strings as well. Most languages support at least some ad-hoc polymorphism, but in languages like C it is restricted to only built-in functions and types. Other languages like C++ allow programmers to provide their own overloading, supplying multiple definitions of a single function, to be disambiguated by the types of the arguments. In Haskell, this is achieved via the system of type classes and class instances.
Despite the similarity of the name, Haskell's type classes are quite different from the classes of most object-oriented languages. They have more in common with interfaces, in that they specify a series of methods or values by their type signature, to be implemented by an instance declaration.
Does it mean that type classes is a way to achieve overloading i.e. ad hoc polymorphism?
What kind of polymorphism does interface in OO languages (e.g. Java, C#) belong to, ad hoc polymorphism (i.e. overloading) or subtype polymorphism?
Since type class is similar to interface, is interface a way to achieve overloading i.e. ad hoc polymorphism, just as type class is?
Is interface similar to base class, so is interface a way to achieve subtype polymorphism, just as class inheritance is?
Thanks.
(forall a. a -> a) ≤ (Int -> Int)
. – dfeuer