In Graham Hutton's book "Programming in Haskell", he defines a function to be polymorphic, if its type "contains one or more type variables". He then defines a function to be overloaded, if its type "contains one or more class constraints".
From these definitions, my question is, "can a function be polymorphic and overloaded?".
For example, the function elem
in the standard prelude, essentially has a type of Eq a => [a] -> Bool
. Can we say that this function is both polymorphic and overloaded?
EDIT:
Graham Hutton said "Given that class constraints can only be used to type variables, my answer would be yes, a function can be called both polymorphic and overloaded. In particular, any overloaded function is by these definitions also polymorphic. However, I can understand why someone may wish to keep a distinction between these two terms. For the purposes of the book I wanted to have clear and simple definitions."
Haskell Wiki page, states that elem
is an example of "ad-hoc polymorphism", whilst something like id :: a -> a
, is an example of "parametric polymorphism".