[Template-haskell] RE: patch applied (ghc): Three improvements to Template Haskell (fixes #3467)

Simon Peyton-Jones simonpj at microsoft.com
Fri Sep 11 04:57:00 EDT 2009


| >   Declaration-level splices with no "$"
| >   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| >   This change simply allows you to omit the "$(...)" wrapper for
| >   declaration-level TH splices.  An expression all by itself is
| >   not legal, so we now treat it as a TH splice.  Thus you can now
| >   say
| >   	data T = T1 | T2
| >    	deriveMyStuff ''T
| 
| Nice.
| 
| There has been talk int the cast about allowing things like
|     class T, type T
| etc in the module export list. Perhaps you should also be able to say
| 
|     data T = T1 | T2
|     deriveMyStuff (type T)
| 
| rather than using the somewhat odd '' syntax.

Interesting idea.  You're making use of the *keyword* 'type', although it's unexpected in an expression context.

Trouble is, we lack a keyword for 'value'!  I suppose we could invent one.  Thus

   module Foo(  type T(..), class C,  value f, value g  )
and
   deriveMyStuff [type T, value f]

I wonder if that would have merit?  What do other TH afficionados think?

Simon



More information about the template-haskell mailing list