core-async 2023-03-22

Hey team, noob question. I am using core-async, and wanted to propagate errors. The solution I've found so far is using <? and go-try The issue though, is that is kid of "colors" every function I use over a channel. For example:

(defn uh-oh-go-try
  []
  (go-try
    (throw (Exception. "uh-oh"))))

(<?? (a/into [] (a/merge [(uh-oh-go-try) (uh-oh-go-try)])))
;; will not throw
I could make wrappers, like into?, which checks for exceptions, but I wonder if there's a better way.

Hey @ben.sless, have you written every and some in the context of core-async by any chance? I'd be curious to take a peak at an example

Don't think I have, but those combinators aren't complicated

👍 1

Basically, some is alts!, every is merge with a little fix that lets you reorder results

Gotcha, thanks Ben! Exciting in a way -- feels like research

You need a "every" and "some", then every before the merge

👍 1

But you're stuck in a monad

You need monadic combinators

every, some and bind, I think are sufficient

you have the same issue if you work with anomalies