On 19/07/2011, at 0:09, Patrick Browne patrick.bro...@dit.ie 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
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
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.
Patrick Browne patrick.bro...@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
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
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 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 =
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 patrick.bro...@dit.ie
On 18/07/2011 19:14, Jerzy Karczmarczuk wrote:
That's why I suggested how you might do that: for
On Mon, Jul 18, 2011 at 3:14 PM, Jerzy Karczmarczuk
jerzy.karczmarc...@unicaen.fr 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
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 penguin?
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
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
Note that no
Quoth Richard O'Keefe o...@cs.otago.ac.nz,
[ ... re Werner Kuhn An Image-Schematic Account of Spatial Categories ... ]
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
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
On 17 July 2011 11:36, Patrick Browne patrick.bro...@dit.ie 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
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...
16 matches
Mail list logo