Proposal for stand-alone deriving declarations?

John Meacham john at
Mon Oct 30 00:13:51 EST 2006

On Mon, Oct 09, 2006 at 01:19:38PM +0100, Simon Peyton-Jones wrote:
> | > I propose to add a top-level declaration on the form:
> | >
> | > 'deriving' qtycls 'for' qtycon
> | >
> | > which produces the same instance as a deriving clause in the
> | > declaration of the datatype or newtype would.
> | 
> | If this is added (whatever the syntax), you'd also want to permit
> multiple
> | identical derived instances.
> Perhaps so.  This might generate duplicate code (one for each decl) but
> it'd be guaranteed identical since it's generated by a deriving clause.
> It'd require some .hi file support, to record that an instance came from
> a 'deriving' decl.
> I'm inclined to wait until someone asks for it "for real" as it were.

I was actually going to request this, but thought it might not play nice
with separate compilation that well. but if the ghc folks don't think it
is too much trouble, I would really like that feature.

I believe you can output some linker pragmas to have the duplicate
bodies merged into one so you won't end up with excess code in your
executable.. but would have to look it up to be sure.


John Meacham - ⑆⑆john⑈

More information about the Haskell-prime mailing list