in clojure.contrib.monad expressions handling conditions in the monad
comprehension are generated by:
(defn- add-monad-step
"Add a monad comprehension step before the already transformed
monad comprehension expression mexpr."
[mexpr step]
(let [[bform expr] step]
(if (identical? bform :when)
(list 'm-bind `(if ~expr (~'m-result ::any) ~'m-zero)
(list 'fn ['_] mexpr))
(list 'm-bind expr (list 'fn [bform] mexpr)))))
Why is it necessary to pass a dummy result in the conditional code:
(if (identical? bform :when)
(list 'm-bind `(if ~expr (~'m-result ::any) ~'m-zero)
(list 'fn ['_] mexpr))
...
Why not:
(if (identical? bform :when)
`(if ~expr ~mexpr ~'m-zero)
.....
as (m-bind m-zero f) <==> m-zero (since we're being pure)
Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---