[Haskell-cafe] Get a variable's type in quasiquote

Jonathan Geddes geddes.jonathan at gmail.com
Thu Jan 5 21:41:47 CET 2012


I'm playing around with Template Haskell, specifically QuasiQuotes and I've
run into something that I hope is not an inherent limitation in TH.

Specifically I want to get the type of a variable whose name is used in a
QuasiQuote. The code generated by the QQ should depend on the type of the
variables that are to be antiquoted.

For example

let a = True
in [qq | a |]

should result in different code being generated by the qq than

let a = 42
in [qq | a |]

because the type of variable "a" is different.

So far I've tried simple reification, but

> quote = do
>let varname = "someVariableKnownToExist"
info <- reify $ mkName str
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120105/08ac2458/attachment.htm>

More information about the Haskell-Cafe mailing list