Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ensure that writer-m-combine returns a list when called with list arg…
…uments
  • Loading branch information
khinsen committed Feb 5, 2014
1 parent 3055d0d commit 7679776
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/clojure/clojure/algo/monads.clj
Expand Up @@ -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))
Expand Down
16 changes: 15 additions & 1 deletion src/test/clojure/clojure/algo/test_monads.clj
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 7679776

Please sign in to comment.