There is also maybe-m monad in clojure.algo.monads . Being part of the monads structure, it is heavier than the macro -?> , So it makes sense to use maybe-m if you use monads anyway or if your computational graph is more complex than a simple chain of functions.
Unlike streaming macros, a domonad composition can handle several argument functions that take arguments from the previous several steps of the calculation:
(domonad maybe-m [a 1 b nil c (* ab)] c)
In this example (* ab) will not be evaluated, since b is zero. The whole expression returns nil instead of throwin an exception to the attempt to multiply by nil.
RafaΕ dowgird
source share