Monad describing stateful computations. The monadic values have the
structure (fn [old-state] [result new-state]).
(defmonad state-m
"Monad describing stateful computations. The monadic values have the
structure (fn [old-state] [result new-state])."
[m-result (fn m-result-state [v]
(fn [s] [v s]))
m-bind (fn m-bind-state [mv f]
(fn [s]
(let [[v ss] (mv s)]
((f v) ss))))
])
Comments top
No comments for state-m. Log in to add a comment.