Thanks Matthias and Sam, the macro expansion now works as I intended, with the following change:<br><br>(define-syntax-rule (with-monad (<unit-f> <bind-f>) <body>) <br> (let ((u <unit-f>)<br> (b <bind-f>))<br>
(syntax-parameterize ([bind (make-rename-transformer #'b)])<br> (syntax-parameterize ([unit (make-rename-transformer #'u)])<br> <body>))))<br>
<br><div class="gmail_quote">2011/7/19 Sam Tobin-Hochstadt <span dir="ltr"><<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, Jul 19, 2011 at 2:06 PM, Ismael Figueroa Palet<br>
<<a href="mailto:ifigueroap@gmail.com">ifigueroap@gmail.com</a>> wrote:<br>
> Hi all, I'm trying to implement some simple macros to use monads in racket<br>
> using a Haskell-like do notation. I have the following macros, and my<br>
> problem is that I want the do macro to capture the bind identifier created<br>
> by with-monad, and in each recursive step of the do macro expansion keep the<br>
> same identifier. I don't know it is possible, I tried using (with-syntax<br>
> ((bind (datum->syntax 'bind) ))) but it doesn't work.<br>
<br>
</div>I think the right solution here is to use syntax parameters [1]. This<br>
blog post by Eli provides a good intro:<br>
<a href="http://blog.racket-lang.org/2008/02/dirty-looking-hygiene.html" target="_blank">http://blog.racket-lang.org/2008/02/dirty-looking-hygiene.html</a><br>
<br>
[1] <a href="http://docs.racket-lang.org/reference/stxparam.html" target="_blank">http://docs.racket-lang.org/reference/stxparam.html</a><br>
<font color="#888888">--<br>
sam th<br>
<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Ismael<br><br>