deriving...
Andres Loeh
andres at cs.uu.nl
Tue Oct 19 14:08:49 EDT 2004
> Simon Peyton-Jones wrote:
> > derive( Typeable (T a) )
> >
> >But that means adding 'derive' as a keyword. Other possibilities:
> >
> > deriving( Typeable (T a) )
> > -- (B) Re-use 'deriving' keyword
> >
> >The trouble with (B) is that the thing inside the parens is different in
> >this situation than in a data type declaration.
> >Any other ideas?
>
> instance Typeable (T a) deriving
Why not even simply
instance Typeable (T a)
In other words, derivable classes define default
implementations for all their methods.
Advantages:
(1) no syntax change at all required
(2) derived class instances can be partially
redefined by the user
Disadvantages:
(1) Slightly more work in some cases because
a complete instance declaration is required.
Example:
instance Eq a => Eq (T a)
Cheers,
Andres
More information about the Glasgow-haskell-users
mailing list