[Haskell-cafe] Subtype polymorphism in Haskell

Simon Courtenage courtenage at gmail.com
Mon Jul 5 09:22:43 EDT 2010


Hi,

I am porting a C++ program to Haskell.  My current task is to take a class
hierarchy and produce something equivalent in Haskell, but I don't seem to
be able to get a grip on how type classes and instances contribute to the
solution.  Can anyone enlighten me?

Roughly, the class hierarchy in C++ is of the form

class A {
public:
   virtual int do_x(int,int) = 0;
};

class B {
public:
   int do_x(int x,int y) { ...}
};

class C {
public:
   int do_x(int x,int y) { ...}
};

Any help would be greatly appreciated.

Thanks

Simon
courtenage at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100705/4c945411/attachment.html


More information about the Haskell-Cafe mailing list