Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure that writer-m-combine returns a list when called with list arg…

…uments
  • Loading branch information...
commit 7679776bbddde7a716b9e077a4f65d1a568fe9c7 1 parent 3055d0d
@khinsen khinsen authored
View
2  src/main/clojure/clojure/algo/monads.clj
@@ -482,7 +482,7 @@
clojure.lang.IPersistentList
(writer-m-add [c v] (conj c v))
- (writer-m-combine [c1 c2] (concat c1 c2))
+ (writer-m-combine [c1 c2] (apply list (concat c1 c2)))
clojure.lang.APersistentSet
(writer-m-add [c v] (conj c v))
View
16 src/test/clojure/clojure/algo/test_monads.clj
@@ -126,6 +126,13 @@
b (m-result 2)]
(+ a b))
[3 [:a :b]]))
+ (is (= (domonad (writer-m ())
+ [_ (write :a)
+ a (m-result 1)
+ _ (write :b)
+ b (m-result 2)]
+ (+ a b))
+ [3 '(:a :b)]))
(is (= (domonad (writer-m (list))
[_ (write :a)
a (m-result 1)
@@ -139,7 +146,14 @@
_ (write :a)
b (m-result 2)]
(+ a b))
- [3 #{:a}])))
+ [3 #{:a}]))
+ (is (= (domonad (writer-m ())
+ [_ (domonad
+ [_ (write "foo")]
+ nil)
+ _ (write "bar")]
+ 1)
+ [1 '("foo" "bar")])))
(deftest reader-monad
(let [monad-value (domonad reader-m
Please sign in to comment.
Something went wrong with that request. Please try again.