
Ralf Lammel wrote:
Cédric Paternotte wrote: ...
5. With this : http://www.cs.utexas.edu/ftp/pub/techreports/tr01-60/tr01-60.pdf
Gracjan Polak wrote:
I've been thinking about slight generalization of this lately. Here are my semi-backed thoughts as of now.
I should have mentioned http://homepages.cwi.nl/~ralf/OOHaskell/src/PoorMens2/ (again *not* using OOHaskell)
From the quick skim of code: .?. -- apply function to upcast object .!. -- apply modification function to upcast object and substitute returned value (new object), basically update Is there any description avaliable what is PoorMens2 all about?
A more general and preliminary observation: the entire approach is potentially more about object *composition* (and perhaps delegation) rather than inheritance. Many OO evangelists consider inheritance as a concept that was used too much in early OO times, while object composition is often more appropriate and flexible. So one *might* say that this approach does not encode a Java-inheritance solution but it does an inheritance-to-object-composition migration on the fly. So what Gracjan calls "Inherits" (and I call subtyping or substitution) is perhaps more a "delegates".
Yes, I agree with this statement. The OP question was: how to simulate inheritance in Haskell? One of the answers: using delegation :)
Ralf
-- Gracjan