leonoel / missionary

A functional effect and streaming system for Clojure/Script
Eclipse Public License 2.0
630 stars 26 forks source link

ditch gather #28

Closed leonoel closed 3 years ago

leonoel commented 3 years ago

gather was useful before ap/?= was a thing, much less now, especially considering amb=.

xificurC commented 3 years ago

Can you elaborate what pattern would substitute gather's usage? I'm working on the RxJava comparison tutorial and the next example merges two Observables, which seems what gather does. After thinking for 10 minutes and sifting through the API I haven't found another way to merge 2 flows.

xificurC commented 3 years ago

Nevermind, I see gather is implemented as

([f & fs] (ap (?? (?= (enumerate (cons f fs))))))

Now just to understand that :)

xificurC commented 3 years ago

enumerate turns a list of flows into a flow of flows. ?= forks the flow of flows into flows running concurrently. ?? picks the next value in each forked process. Not bad.

With amb= this would be (ap (?? (amb= f1 f2 f3 ...))), right?

leonoel commented 3 years ago

deprecated b.19

dustingetz commented 1 year ago

(defn mix [& flows] (m/ap (m/?> (m/?> (count flows) (m/seed flows)))))

dustingetz commented 1 year ago

Leo says: "I want to minimize the surface API and encourage usage of primitive operators instead. If this operator exists then a dozen other combinations deserve to exist too"