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
> 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 t
On 19/07/2011, at 0:09, Patrick Browne wrote:
> instance Bird Emperor where
> -- No fly method
> walk x y = y
>
> instance Penguin Emperor where
> -- How can I override the walk method in the instance Penguin?
> -- walk x y = x
Why would you want to override the walk method for Emperor?
Quoth "Richard O'Keefe" ,
[ ... re Werner Kuhn "An Image-Schematic Account of Spatial Categories" ... ]
> class BUILDING building where
>
> class BUILDING house => HOUSE house where
>
> any instance of HOUSE *will* have in its interface everything that
> any instance of BUILDING will.
But .
On 19/07/2011, at 11:09 AM, Patrick Browne wrote:
> data Emperor = Emperor
> data Robin = Robin
>
> class Bird a where
> fly :: a -> a -> a
> walk :: a -> a -> a
>
> instance Bird Robin where
> fly x y = y
> walk x y = x
>
> instance Bird Emperor where
> -- No fly method
> walk x y = y
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 pape
On Tue, 2011-07-19 at 01:13 +0200, Yves Parès wrote:
> Oh, I got it: You want to have:
>
> class Bird b where
>
> class Penguin p where
>
> instance (Penguin b) => Bird b where
>fly = -- fly method for penguins
>
I haven't followed the thread carefully but why does the bird have to be
a pe
On Mon, Jul 18, 2011 at 3:14 PM, Jerzy Karczmarczuk
wrote:
> 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.
Instead of flying, they'
Oh, I got it: You want to have:
class Bird b where
class Penguin p where
instance (Penguin b) => Bird b where
fly = -- fly method for penguins
2011/7/19 Patrick Browne
> On 18/07/2011 19:14, Jerzy Karczmarczuk wrote:
> > That's why I suggested how you might do that: for some datatypes, say
On 18/07/2011 19:14, Jerzy Karczmarczuk wrote:
> 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.
-- Here is my attempt
data Emperor =
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
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, s
Patrick Browne 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
B
Patrick Browne :
> For example, if the class Bird has a flying method can we represent
Penguins
> as a sub-class of Bird without a flying method?
The silliest - from the pedagogical perspective - answer to any
question, is "you don't need it".
But ... in most cases you really don't need it..
On 17 July 2011 11:36, Patrick Browne wrote:
> Hi,
> 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?
Possibly with duck typing[1], but that's no
Hi,
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?
Regards,
Pat
This message has been scanned for content and viruses by the DIT Information
Servi
16 matches
Mail list logo