On Sun, Nov 20, 2005 at 04:21:05PM +0100, Wolfgang Jeltsch wrote: > Am Samstag, 19. November 2005 17:35 schrieb Bulat Ziganshin: > > 7. OOP-like fields inheritance: > > > > data Coord = { x,y :: Double } > > data Point : Coord = { c :: Color } > > > > of course this is just another sort of syntax sugar once we start > > using classes to define getter/setter functions > > I thought that even many OO people say that inheritance of fields is not > good practice. So why should we want to support it?
Think of it instead as being syntactic sugar for a class declaration: class Coord a where get_x :: a -> Double get_y :: a -> Double set_x :: Double -> a -> a set_y :: Double -> a -> a Coord might not be the best example, but I'd certainly like to be able to automatically derive this sort of class functionality without writing lots of boiler-plate instances. -- David Roundy http://www.darcs.net _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe