
What I implemented in GHC is an extension of the proposal below. The proposal just mentions: deriving Class for Type In GHC I also added a form for newtype deriving of multi-parameter type classes: deriving (Class t1 ... tn) for Type I think that it's close to what we ended up with when talking about it at the Hackathon. My intuition about this syntax is that except for the "for Type" part, it looks the same as a normal deriving clause. The "for" part is just there to connect it to a data/newtype declaration. This lets it pretty much use the normal code for deriving declarations. Stand-alone deriving declarations are currently a little bit weaker than normal deriving clauses, since the current implementation does not let you reference the type arguments of a newtype in the arguments of an MPTC. See my response to Bulat on cvs-ghc@haskell.org for more details. /Björn On 5 okt 2006, at 10.36, Simon Peyton-Jones wrote:
Thanks for doing this.
Is this the syntax we settled on? I remember we discussed it at some length
S
| -----Original Message----- | From: haskell-prime-bounces@haskell.org [mailto:haskell-prime- bounces@haskell.org] On Behalf Of | Bjorn Bringert | Sent: 05 October 2006 09:05 | To: haskell-prime@haskell.org | Subject: Proposal for stand-alone deriving declarations? | | On http://hackage.haskell.org/trac/haskell-prime/wiki/ | DerivedInstances it says: | | "- There is no way to derive an instance of a class for a data type | that is defined elsewhere (in another module)." | | Though there is no proposal to fix this. Would such a proposal be | appropriate for Haskell'? | | | If so, 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. | | | I have recently (thanks to the GHC Hackathon) implemented this in GHC. | | /Björn | | _______________________________________________ | Haskell-prime mailing list | Haskell-prime@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-prime