Here http://en.wikibooks.org/wiki/Haskell/Classes_and_types in section Class inheritance, I read “A class can inherit from several other classes: just put all the ancestor classes in the parentheses before the =>.”
I am puzzled when “(…)=>” is described as “inheritance”. So far as I can see, it’s simply a class constraint. It merely says that this newly defined class (in the example: Real) applies to types which are already members (have instances for) the listed classes (Num and Ord).
In short, the “(…)=>” seems to me to act like a filter for qualities required of the types for which instances of this class may be created, and does not act to augment either the class or its instances.
Am I missing something? Is there some sense in which the “(…)=>” actually passes something along from “parent” to “child”?
In practice, this means that all members of the subclass necessarily provide all methods of the superclass.
So, as in the linked example, we can write a method that requires
Eq, but only give it anOrdconstraint, and theEqmethods are implied for us.(Note that inheritance is probably a terrible term for this, because it carries a lot of associations that don’t make sense in our context. Nonetheless, I figured I might as well explain it.)