From 8ac0ee794e96f529ec40421b8ac69ddc2c83d910 Mon Sep 17 00:00:00 2001 From: rebcabin Date: Sun, 29 Dec 2013 07:43:24 -0800 Subject: [PATCH 1/2] Change m-chain docstring changed example in docstring to a vector of steps instead of an unquoted list of steps. The latter gives false impression that m-chain might be a macro that doesn't evaluate the list. --- src/main/clojure/clojure/algo/monads.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/clojure/clojure/algo/monads.clj b/src/main/clojure/clojure/algo/monads.clj index fa2dfb1..b9757c5 100644 --- a/src/main/clojure/clojure/algo/monads.clj +++ b/src/main/clojure/clojure/algo/monads.clj @@ -276,7 +276,7 @@ (defmonadfn m-chain "Chains together monadic computation steps that are each functions of one parameter. Each step is called with the result of the previous - step as its argument. (m-chain (step1 step2)) is equivalent to + step as its argument. (m-chain [step1 step2]) is equivalent to (fn [x] (domonad [r1 (step1 x) r2 (step2 r1)] r2))." [steps] (reduce (fn m-chain-link [chain-expr step] From f3867fb9dd0602fea7c037af979864cc3fa623fa Mon Sep 17 00:00:00 2001 From: rebcabin Date: Sun, 29 Dec 2013 09:37:15 -0800 Subject: [PATCH 2/2] Further clarify m-chain docstring Add the missing monad specifier, which must appear but in different positions. --- src/main/clojure/clojure/algo/monads.clj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/clojure/clojure/algo/monads.clj b/src/main/clojure/clojure/algo/monads.clj index b9757c5..4a9c79d 100644 --- a/src/main/clojure/clojure/algo/monads.clj +++ b/src/main/clojure/clojure/algo/monads.clj @@ -276,8 +276,10 @@ (defmonadfn m-chain "Chains together monadic computation steps that are each functions of one parameter. Each step is called with the result of the previous - step as its argument. (m-chain [step1 step2]) is equivalent to - (fn [x] (domonad [r1 (step1 x) r2 (step2 r1)] r2))." + step as its argument. + (with-monad some-m (m-chain [step1 step2])) + is equivalent to + (fn [x] (domonad some-m [r1 (step1 x) r2 (step2 r1)] r2))." [steps] (reduce (fn m-chain-link [chain-expr step] (fn [v] (m-bind (chain-expr v) step)))