[Haskell-cafe] partial inheritance

Richard O'Keefe ok at cs.otago.ac.nz
Tue Jul 19 04:59:42 CEST 2011


On 19/07/2011, at 5:09 AM, Patrick Browne wrote:

> On 18/07/2011 13:52, Ketil Malde wrote:
>> 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.
> 
> I am actually doing a language comparison and I was checking out a paper
> that said:
> "Type classes allow for partial inheritance, so that penguins can be
> birds without flying behavior."

That would be "An Image-Schematic Account of Spatial Categories"
by Werner Kuhn, I take it?  His e-mail address is at the top of
the paper, so why not ask him?  I cannot find anything in the
Haskell 2010 report that says anything about partial inheritance.

In his example,
class BUILDING building where <specify the behavior of buildings here, if any>
class BUILDING house => HOUSE house where <specify additional behavior of houses here, if any>
any instance of HOUSE *will* have in its interface everything that
any instance of BUILDING will.  As has already been pointed out,
the implementation of something may be (or call) 'undefined',
but this is rather boring; even Smalltalk-80 let you plug in
"self shouldNotImplement" as the definition of a method.

If you want a language where a subclass can remove features from the
interface(s) of its superclass(es), you probably want Eiffel, not Haskell.

> But as pointed out by Jerzy my question is silly because can penguins
> can fly:
> On 17/07/2011 11:14, Jerzy Karczmarczuk wrote:
>>> PS. Penguins DO fly.
>>> http://www.telegraph.co.uk/news/worldnews/1583517/Flying-penguins-found-by-BBC-programme.html

And what a fine April Fool's joke that was.  But even in that joke,
flying was something "no other penguins can do".




More information about the Haskell-Cafe mailing list