missionary 2024-09-19

In an ap block, if I have a task that fails, let's say it returns nil, and I don't want that nil to end up the flow what is the idiomatic way to deal with it?

I guess that's where amb magic comes into play?

(m/? (m/reduce (fn [out x] (conj out x)) [] (m/ap (let [x (m/?> (m/seed [1 nil 3]))] (or x (m/amb))))))
[1 3]

(m/? (m/reduce (fn [out x] (conj out x)) [] (m/ap (let [x (m/?> (m/seed [1 nil 3]))] (when-not x (m/amb)) x))))
[1 3]

Absolute Negativity 2024-09-19T15:58:34.940449Z

(m/eduction (remove nil?) (m/seed ...)) also works.

but I assume the eduction version is doing more work\

Yes, when producing a value from a flow, x is the same as (m/amb x); (m/amb x y z) produces three values; (m/amb) produces no values.