[Haskell-cafe] partial inheritance
Jerzy Karczmarczuk
jerzy.karczmarczuk at unicaen.fr
Mon Jul 18 20:14:42 CEST 2011
Patrick Browne :
> I was checking out a paper that said: "Type classes allow for partial
inheritance, so that penguins can be birds without flying behavior."
> ... as pointed out by Jerzy my question is silly because can penguins
can fly ...
No, the question is not silly because of that crazy Adelie tribe. The
question is doubtful, because the Haskell type classes is not an
object-oriented system of classes, subclasses, etc. When you declare
Rationals, you don't "inherit" the multiplication for them as Numbers.
This "inheritance" you wish may manifest itself when you specify the
*instances*.
That's why I suggested how you might do that: for some datatypes, say
the Emperors, you specify some special flying method (e.g. dummy or
bombing), or you don't specify it at all. And the Emperors won't fly.
Jerzy Karczmarczuk
More information about the Haskell-Cafe
mailing list