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.
Thanks (module monad racket (provide with-monad do) (define-syntax-rule (with-monad (<unit-f> <bind-f>) <body>) (let ((unit <unit-f>) (bind <bind-f>)) <body>)) (define-syntax (do stx) (syntax-case stx (let let* letrec letrec* <-) ((do s) #'s) ((do (x <- s) ss ...) #'(bind (lambda (x) (do ss ...)) s)) ((do (let bs) ss ...) #'(let bs (do ss ...))) ((do (let* bs) ss ...) #'(let* bs (do ss ...))) ((do (letrec bs) ss ...) #'(letrec bs (do ss ...))) ((do (letrec* bs) ss ...) #'(letrec* bs (do ss ...))) ((do s ss ...) #'(bind s (lambda (_) (do ss ...)))))) ) -- Ismael
_________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users