leonoel / missionary

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

amb operators, sequential and parallel #27

Closed leonoel closed 3 years ago

leonoel commented 3 years ago

Just syntactic sugar. Inside an ap block, amb? and amb= evaluate an arbitrary number of branches ambiguously, respectively sequentially or in parallel.

(defmacro amb? [& forms]
  `(case (m/?? (m/enumerate (range ~(count forms))))
     ~@(interleave (range) forms)))
(defmacro amb= [& forms]
  `(case (m/?= (m/enumerate (range ~(count forms))))
     ~@(interleave (range) forms)))
xificurC commented 3 years ago

amb? looks like a predicate, which confuses my brain. How about one of

leonoel commented 3 years ago

I would discard the third option because amb is an old and known idea, so hiding it behind a symbol is likely to add confusion for nothing. Please share your thoughts about naming in general in #29

leonoel commented 3 years ago

released b.19