[Haskell-beginners] Equivalent of inheritance in Haskell

Antoine Latter aslatter at gmail.com
Mon Dec 13 18:50:34 CET 2010


In OO languages I try not to use inheritance just because I want
re-use - I tend to lean more towards having an instance of class A
contain or wrap around an instance of class B - I will only use
inheritance if A truly is a more specific version of B. Even then I
try to make sure there aren't clearer ways of expressing what I want.

This approach applies perfectly well to types in Haskell - compound
types can be composed of values of other types.

But there is not a way to easily say (in Haskell) "type A is
everything that type B is plus these other things here ...". Haskell
is not an OO language.

Antoine

On Mon, Dec 13, 2010 at 11:16 AM, C K Kashyap <ckkashyap at gmail.com> wrote:
> Hi,
> In oops, one can do reuse code by extending a parent class. What is
> the equivalent in Haskell?
> Regards,
> Kashyap
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



More information about the Beginners mailing list