[Template-haskell] quasi quotes and Q monad

Ch. A. Herrmann herrmann at infosun.fmi.uni-passau.de
Tue Jan 3 10:13:53 EST 2006


Hi Bulat,

Bulat Ziganshin wrote:

>Hello Ch.,
>
>Monday, January 02, 2006, 9:36:03 PM, you wrote:
>
>CAH> maybe you misunderstood me. Take the example of the ST monad. If you are
>
>i feel that it will be clearer if you will compare Q with IO monad
>
>
>  
>
the comparison doesn't work with the IO monad because the user runs the
Q monad every time when splicing a generated expression.
In contrast, the user can't run the IO monad out of a functional non-monadic
expression, except when making use of unsafe features.
Concerning the ST monad (for simplicity, consider one defined by the user
without local type quantification) it is possible, in principle, to join 
the states of
two ST runs overlapping in time, if you have a concept of what you would 
like to
achieve, may depend on the application.

Tomasz mentioned an important point: the monad laws for return. As long as
they are respected by the quasi quote implementation, a return cannot 
destroy
monadic information in the scope where the splice is inserted, so it is 
safe to
turn an Exp into a (Q Exp) just be using return. How to generate the names
inside this Exp is the job of the user, at the point where the spliced 
expression
was created there should be a Q monad available with an appropriate
name generation history. As long as the expression to be spliced is 
taken from the same
scope, and this is the case in simple examples, there is no problem 
because the  expression
need not be passed as a parameter but can just be cited, even across 
quotation brackets 
due to cross-stage persistence.

However, I think, with Tomasz remark we should not worry further about
that point.
--
 Christoph




More information about the template-haskell mailing list