[Haskell-cafe] records proposals list

Wolfgang Jeltsch wolfgang at jeltsch.net
Mon Nov 21 08:48:48 EST 2005


Am Montag, 21. November 2005 14:27 schrieb David Roundy:
> 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

As I pointed out in another e-mail just sent, this kind of special syntax only 
solves a very specific problem so that it's questionable whether this syntax 
should be included into Haskell.  However, if we manage to create a more 
generalized approach, inclusion of it into the language might be quite fine.

In addition, having a line which begins with "data" declaring a class is 
*very* misleading, in my opinion.

> [...]

Best wishes,
Wolfgang


More information about the Haskell-Cafe mailing list