Quasi quoting
Henrik Nilsson
nhn at Cs.Nott.AC.UK
Mon Feb 1 07:52:25 EST 2010
Dear all,
George and I have been discussing this.
We very much support the idea of allowing QQ for top-level
definitions.
Additionally, we think QQ should be allowed for *types*,
just like TH, by extending the record of functions in the following way:
data QuasiQuoter = QuasiQuoter {
quoteExp :: String -> Q Exp
quotePat :: String -> Q Pat
quoteDec :: String -> Q [Dec]
quoteType :: String -> Q Type
}
We have been discussing the need for this
for some time, and if Kathleen hadn't effectively
beaten us to it, we'd have made inquiries for the feasibility
of such a facility shortly anyway.
Additionally, this would make the functionality of TH and QQ more
uniform.
As to syntax, Both George and I prefer [name| ... |].
Yes, it clashes with list comprehensions, but users who use this
facility just have to be aware of that caveat. And, as Simon says,
this is already the case for TH.
It is true that QQ in some ways is rather different from TH. But,
from a user perspective, they're both about *meta programming*,
and thus it makes sense to adopt a similar syntax for the two where
"name" can be seen as a keyword to specify the kind of meta-programming
one is doing. Including the empty string ([|) for the default case,
basic TH expressions.
Best,
George and Henrik
--
Henrik Nilsson
School of Computer Science
The University of Nottingham
nhn at cs.nott.ac.uk
More information about the Glasgow-haskell-users
mailing list