[Haskell-cafe] partial inheritance

Ketil Malde ketil at malde.org
Mon Jul 18 14:52:00 CEST 2011


Patrick Browne <patrick.browne at dit.ie> writes:

> Is it possible to model partial inheritance using Haskell type classes?
> For example, if the class Bird has a flying method can we represent
> Penguins as a sub-class of Bird without a flying method?

I'm not sure the question makes sense, if "fly" is a method of class
Bird, then it can't also be a member of class Penguin.

You can of course make instances of Bird without implementing the "fly"
method (whether they are also instances of Penguin or not), or by
implementing it as "undefined".

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants



More information about the Haskell-Cafe mailing list