[Haskell-cafe] records proposals list

Wolfgang Jeltsch wolfgang at jeltsch.net
Sun Nov 20 10:21:05 EST 2005


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?

A point is not a special coordinate pair.  Instead it has a coordinate paar as 
one of its properties.  So the above-mentioned problem would be better 
handled this way:

	data Coord { x, y :: Double }
	data Point = Point {coord :: Coord, c :: Color }

> [...]

Best wishes,
Wolfgang


More information about the Haskell-Cafe mailing list