Thanks Matthias and Sam, the macro expansion now works as I intended, with the following change:
(define-syntax-rule (with-monad (<unit-f> <bind-f>) <body>) (let ((u <unit-f>) (b <bind-f>)) (syntax-parameterize ([bind (make-rename-transformer #'b)]) (syntax-parameterize ([unit (make-rename-transformer #'u)]) <body>)))) 2011/7/19 Sam Tobin-Hochstadt <sa...@ccs.neu.edu> > On Tue, Jul 19, 2011 at 2:06 PM, Ismael Figueroa Palet > <ifiguer...@gmail.com> wrote: > > Hi all, I'm trying to implement some simple macros to use monads in > racket > > using a Haskell-like do notation. I have the following macros, and my > > problem is that I want the do macro to capture the bind identifier > created > > by with-monad, and in each recursive step of the do macro expansion keep > the > > same identifier. I don't know it is possible, I tried using (with-syntax > > ((bind (datum->syntax 'bind) ))) but it doesn't work. > > I think the right solution here is to use syntax parameters [1]. This > blog post by Eli provides a good intro: > http://blog.racket-lang.org/2008/02/dirty-looking-hygiene.html > > [1] http://docs.racket-lang.org/reference/stxparam.html > -- > sam th > sa...@ccs.neu.edu > -- Ismael
_________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users