Proposal for stand-alone deriving declarations?

Björn Bringert bringert at cs.chalmers.se
Fri Oct 6 08:29:13 EDT 2006


Ketil Malde wrote:
> "Iavor Diatchki" <iavor.diatchki at gmail.com> writes:
> 
>> A question about the syntax:  would there be a problem if we made the
>> 'deriving' declaration look like an instance?
> 
> And you might as well keep the 'instance' keyword when instantiating,
> even if the instance is derived?  Seems more consistent to me
> ('deriving' feels more like a kind of parameter to 'data'
> declarations) and avoids introducing a new keyword, except in the
> context of instance declarations.
> 
>> deriving Show SomeType
>> deriving Eq (AnotherType a)
> 
>   instance Show Sometype derived
>   instance Eq (AnotherType a) where (==) = ...
> 
> -k

One problem with this is that there is no context in the declaration, e.g.:

instance Eq (AnotherType a) derived

Although the generated instance does have one:

instance Eq a => Eq (AnotherType a) where
  ...

(depending on how a is used by the data constructors of AnotherType).

This goes back to the argument I was making earlier about the 
differences between instance and deriving declarations.

/Björn


More information about the Haskell-prime mailing list