
(oops, sorry, didn't do reply to all)
I use haskell-src-meta in QuasiText (on hackage) also. It would certainly
be nice to have "native" anti-quotations, but for now haskell-src-meta does
a very good job.
Mike
On Sat, May 26, 2012 at 8:31 AM, Geoffrey Mainland
On 05/25/2012 21:46, Antoine Latter wrote:
On Fri, May 25, 2012 at 2:51 PM, Sam Lindley
wrote: Template Haskell supports antiquotation for built-in quasiquotes, e.g.:
[| \x -> x + $([|3 * 4|]) |]
However, as far as I can tell, there is no way of supporting antiquotation in user-defined quasiquoters, because the only way to specify a new quasiquoter is through a quoteExp function of type String -> Q Exp. Of course, it is perfectly possible to write a parser for some fragment of Haskell inside your quoteExp function, but that seems crazy given that Template Haskell or rather GHC already implements a parser for the whole language.
I know about Language.Haskell.Exts.Parser in haskell-src-exts, which provides parseExp :: String -> ParseResult Exp, but that Exp is a different type to the one provided by Template Haskell.< http://hackage.haskell.org/packages/archive/haskell-src-exts/1.9.0/doc/html/...
I'm also aware of Dominic Orchard's syntax-trees package, which supports converting between the two representations using a cunning hack that pretty-prints the haskell-src-exts representation to a string and uses Template Haskell to parse it back.
Is there a saner way of simulating antiquotation in user-defined quasiquoters?
Have you looked at:
http://hackage.haskell.org/package/haskell-src-exts-qq http://hackage.haskell.org/package/haskell-src-meta
The might help you pull something together.
Antoine
Sam
I use haskell-src-meta in language-c-quote (also on hackage) to support antiquotation and heartily endorse it. I have not used haskell-src-exts-qq.
Geoff
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe