Proposal: Overloaded Quotes for Template Haskell
Simon Peyton-Jones
simonpj at microsoft.com
Sat Dec 31 02:05:57 CET 2011
| Currently quote forms have type "Q Exp" and nested splices expect
| their contents to have type "Q Exp". I propose that quote forms have
| type "forall m. Quasi m => m Exp" and nested splices expect a body of
| type "m Exp" where the "m" of the nested splice is the same as the "m"
| of the quote form that it is inside of.
Happily they already have that type. Have a look in Language.Haskell.TH.Syntax:
newtype Q a = Q { unQ :: forall m. Quasi m => m a }
You want a function from "Q Exp" to "forall m. Quasi m => m Exp". It would have type
Q Exp -> forall m. Quasi m => m Exp
or, isomorphically
forall m. Quasi m => Q Exp -> m Exp
And indeed there is such a function: it's called runQ.
So I think what you want is already available.
Happy new year
Simon
More information about the Libraries
mailing list