[Haskell-cafe] How to fulfill the "code-reuse" destiny of OOP?

Magnus Therning magnus at therning.org
Fri Oct 30 03:15:30 EDT 2009


On 30/10/09 05:32, Rogan Creswick wrote:
> On Thu, Oct 29, 2009 at 6:54 PM, Magicloud Magiclouds
> <magicloud.magiclouds at gmail.com>  wrote:
>>   My concern here is about the data member inheriting. In OOP, when I
>> inherit a class, I also got the members of it. But in haskell, how to
>> inherit a "data"?

[..]

> The point of that whole rant is that extending data-bearing classes isn't
> necessarily a good idea, so before trying to find a way to do it with
> haskell, it may be better to just encapsulate another data type, which is
> trivial:
>
> data InnerThing = A | B | C
>
> data OuterThing = Outer { innerThing :: InnerThing, otherField :: Int }

IIRC James Gosling once said that if he were to design Java today he would
leave out classes.  I suppose partly due to many of the issues with "data
inheritance".

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe



More information about the Haskell-Cafe mailing list