simonpj at microsoft.com
Mon Feb 1 13:49:43 EST 2010
| quotations of the form [| .... |] (i.e. no 'language' specified) will
| use an implicit parameter* ('quasi', say) of type QuasiQuoter, if in
| scope. Otherwise, they will behave as they currently do (TH
| expression quotation?). Now to awaken the 'pads' magic (or some other
| magic), you'd do this somewhere:
| quasi = pads
Nice idea, but won't work as specified. The thing is that the quasiquoter is run at *compile time*. So it can't be an implicit parameter, which is by definition only available at runtime
f :: (?q:QuasiQuoter) => ..blah...
A variant of your suggestion would be: for any quote [|..blah..|] behave as if the programmer had written [quasiQuoter| ...blah...|]. That is, simply pick up whatever record named "quasiQuoter" is in scope. Then you'd say
import Pads( quasiQuoter )
and away you go. But you can only use one at a time.
That might be quite convenient, but alas [|...|] has already been taken by Template Haskell quotes, meaning [e| ...|]. So you'd need something else. [*|...|] perhaps.
Or we could switch to different quotation brackets altogether for quasiquotation, the obvious possibility being <|...blah...|>, and <pads|...blah...|>. That would not be hard, and would only affect the handful of current quasiquote users. But it'd remove "<|" and "|>" as a valid operators, at least for quasiquote customers. I don't know how bad that would be.
More information about the Glasgow-haskell-users