Fork me on GitHub
#core-async
<
2016-01-08
>
rkoch09:01:38

Hi, I have an issue getting clojure.core.async/pipeline-blocking to work on Clojure 1.6:

(require
    '[clojure.core.async :as a])
  (def ch1 (a/chan))
  (def ch2 (a/chan))

  (a/go-loop []
    (when-some [msg (a/<! ch2)]
      (println "Arrived on ch2: " msg)
      (recur)))

  (a/pipeline-blocking
    1
    ch2
    (fn [value] (println "Value in pipeline: " value) value)
    ch1)

  (a/>!! ch1 1)

  ;; prints:
  ;; Value in pipeline:  #<protocols$add_BANG_ [email protected]>
I understand that transducers are not available yet in Clojure 1.6 and that might be the problem. Is there a way to still getting this to work without having to implement pipeline-blocking myself? Thanks.

alexmiller11:01:53

Transducers are just functions so they do "work" in 1.6, you just have to define them yourself

alexmiller11:01:18

There's an example in the async tests

rkoch12:01:49

@alexmiller: now it works, thank you! so mapping imitates native transducer functionality?

alexmiller13:01:31

It's the exact same thing - that's basically copy/paste

alexmiller13:01:09

Transducers are just functions