The Future of Haskell discussion at the Haskell Workshop

Robert Ennals Robert.Ennals@cl.cam.ac.uk
Wed, 10 Sep 2003 11:12:31 +0100


> Yes, things are clearer and I rather like the idea. The only
> thorny issue is that the update function for field 'wibble'
> is formed from but not equal to the field name itself.
> 
> In short, the magic thing would be in the 'deriving' clause:
> 
> If the data type declares fields with names x_1, ..., x_n
> and the class mentioned declares operators y_1, ..., y_k
> and set_y_1, ..., set_y_k where {y_1, ..., y_k} is a subset
> of {x_1, ..., x_k}, of the appropriate types, then the
> corresponding instance declarations are generated.

Yep. 

It would also be possible for a class to declare only the selector or only the 
updater for a field. E.g.:

class FooGet a where
    foo :: a -> Int

class FooSet a where
    set_foo :: Int -> a -> a


data Bar = Bar {foo :: Int}
    deriving (FooGet, FooSet)



-Rob