[Haskell-cafe] Quasi quotation question

Sterling Clover s.clover at gmail.com
Fri Nov 19 19:21:20 EST 2010

On Nov 19, 2010, at 6:00 PM, jean-christophe mincke wrote:

> Hello,
> Is it possible for a quasi quoter to have access to information about haskell identifiers declared before the quasi-quotation?  

Nope. There are staging restrictions in place, since you can't sanely use things that haven't been fully defined and typechecked yet. Quasiquotation in fact runs at the renaming stage, before there's been any typechecking of the module yet, so the situation is even more dire.

> I tried the 'reify' function but without success.
> Just as in the following exemple:
> a = 6
> x = [$expr|a|]  

However, in your example, you just want to generate `x = a`. You can do that just fine! Just generate a syntax tree that includes a variable named a. If there's no variable named a, or it has the wrong type, the syntax tree is still generated just fine -- the error just comes at the typechecking phase. It would be generating x = 6 that is impossible.


More information about the Haskell-Cafe mailing list