
25 Feb
2007
25 Feb
'07
11:26 p.m.
Steve Downey wrote:
So, I've been working on a Composite example. I've used existential types to have a generic proxy to the base type, rather than a simple algebraic type, since adding new leaves to the algebraic type means modifying the whole type, a violation of the Open-Closed principle (open for extension, closed for modification)
Rather than using existential types, a simple record of functions can be often be useful. ie: data Component = Component { draw :: String add :: Component -> Component } It might be worth comparing this approach with the (more complex) one you have described. Tim