diff --git a/include/monad-tests.lfe b/include/monad-tests.lfe index 8aa03b2..cb6b4b9 100644 --- a/include/monad-tests.lfe +++ b/include/monad-tests.lfe @@ -12,14 +12,14 @@ (return ,monad 1)))) (deftest monad-do (is-equal (return ,monad 'ok) - (do ,monad - (return ,monad 'ignored) - (return ,monad 'ok)))) + (do-m ,monad + (return ,monad 'ignored) + (return ,monad 'ok)))) (deftest monad-do-binding (is-equal (return ,monad 9) - (do ,monad - (a <- (return ,monad 3)) - (return ,monad (* a a))))) + (do-m ,monad + (a <- (return ,monad 3)) + (return ,monad (* a a))))) (deftest monad-sequence (is-equal (return ,monad (list 1 2 3)) (sequence ,monad (list (return ,monad 1) @@ -50,26 +50,26 @@ (deftest monad-do-left-identity (let ((a 3) (f (lambda (n) (return ,monad (* 3 n))))) - (is-equal (do ,monad (a' <- (return ,monad a)) - (funcall f a')) - (do ,monad (funcall f a))))) + (is-equal (do-m ,monad (a' <- (return ,monad a)) + (funcall f a')) + (do-m ,monad (funcall f a))))) (deftest monad-do-right-identity (let ((m (return ,monad 3))) - (is-equal (do ,monad (x <- m) - (return ,monad x)) - (do ,monad m)))) + (is-equal (do-m ,monad (x <- m) + (return ,monad x)) + (do-m ,monad m)))) (deftest monad-do-associativity (let ((m (return ,monad 3)) (f (lambda (n) (return ,monad (* 3 n)))) (g (lambda (n) (return ,monad (+ 5 n))))) - (is-equal (do ,monad (y <- (do ,monad (x <- m) - (funcall f x))) - (funcall g y)) - (do ,monad (x <- m) - (do ,monad (y <- (funcall f x)) - (funcall g y)))))) + (is-equal (do-m ,monad (y <- (do-m ,monad (x <- m) + (funcall f x))) + (funcall g y)) + (do-m ,monad (x <- m) + (do-m ,monad (y <- (funcall f x)) + (funcall g y)))))) )) (defmacro test-monad (monad) diff --git a/include/monads.lfe b/include/monads.lfe index b3f3c15..a5f7d1d 100644 --- a/include/monads.lfe +++ b/include/monads.lfe @@ -1,4 +1,4 @@ -(defmacro do args +(defmacro do-m args (let ((monad (car args)) (statements (cdr args))) (monad:do-transform monad statements))) @@ -19,7 +19,7 @@ ,list)) (defmacro mcons (monad m mlist) - `(do ,monad - (x <- ,m) - (rest <- ,mlist) - (return ,monad (cons x rest)))) + `(do-m ,monad + (x <- ,m) + (rest <- ,mlist) + (return ,monad (cons x rest)))) diff --git a/test/unit/unit-maybe-monad-tests.lfe b/test/unit/unit-maybe-monad-tests.lfe index f9209fa..4f0383a 100644 --- a/test/unit/unit-maybe-monad-tests.lfe +++ b/test/unit/unit-maybe-monad-tests.lfe @@ -38,13 +38,13 @@ (deftest do-bindings (is-equal #(just 3) - (do maybe-monad + (do-m maybe-monad (a <- #(just 1)) (b <- #(just 2)) (return maybe-monad (+ a b))))) (deftest do-nobindings (is-equal #(just 3) - (do maybe-monad + (do-m maybe-monad #(just 5) #(just 3))))