[Haskell-cafe] partial inheritance
Maciej Piechotka
uzytkownik2 at gmail.com
Tue Jul 19 11:44:04 CEST 2011
On Tue, 2011-07-19 at 10:43 +0200, Yves Parès wrote:
> > I haven't followed the thread carefully but why does the bird have
> to be a penguin?
>
> A bird doesn't have to be a penguin :
>
> instance (Penguin b) => Bird b where
> fly = -- fly method for penguins
>
> Says that every Penguin is a Bird.
> But thinking back about it, there is a problem when trying to define
> the method walk, because:
>
> class Penguin p where
> walkPenguin :: ....
>
> instance (Penguin b) => Bird b where
> fly = .....
> walk = walkPenguin
>
> is kind of awful, because walk has to be duplicated. So, not the best
> way to go...
Note to self: don't respond to ml after 2am. I saw instance but read
class.
Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110719/6302ef87/attachment.pgp>
More information about the Haskell-Cafe
mailing list