(defn writer-m
"Monad describing computations that accumulate data on the side, e.g. for
logging. The monadic values have the structure [value log]. Any of the
accumulators from clojure.contrib.accumulators can be used for storing the
log data. Its empty value is passed as a parameter."
[empty-accumulator]
(monad
[m-result (fn m-result-writer [v]
[v empty-accumulator])
m-bind (fn m-bind-writer [mv f]
(let [[v1 a1] mv
[v2 a2] (f v1)]
[v2 (clojure.contrib.accumulators/combine a1 a2)]))
]))
Vars in
clojure.contrib.monads/writer-m:
defn
Used in 0 other vars
Comments top
No comments for writer-m. Log in to add a comment.