I am trying to wrap my head around the sequence monad in query.
I have this code that creates a sequence monad using clojure.algo.monads:
(use 'clojure.algo.monads)
(def sequence-monad-decider
(fn [step-value monadic-continuation]
(mapcat monadic-continuation step-value)))
(def sequence-monad-monadifier list)
(def sequence-monad
(monad [m-result sequence-monad-monadifier
m-bind sequence-monad-decider]))
(prn
(with-monad sequence-monad
(domonad [a [1 2]
b [10, 100]
c [-1 1]]
(* a b c))))
So I understand that m-bind will be used to pass a step value and a continuation to sequence-monad-decider
.
sequence.monad-decider
is defined like this:
(def sequence-monad-decider
(fn [step-value monadic-continuation]
(mapcat monadic-continuation step-value)))
so if we look at calling the monad:
(prn
(with-monad sequence-monad
(domonad [a [1 2]
b [10, 100]
c [-1 1]]
(* a b c))))
With binding a
of the above, [1 2]
will be passed as the step value to sequence.monad.decider
but what is the monadic-continuation
function that is passed as the second argument to this function?