Fork me on GitHub
#core-async
<
2019-01-03
>
mrchance16:01:37

Is there a reason why tap doesn't have a transducer form? Is there a better way to link a mult to another channel via a transducer than through an intermediate channel?

Alex Miller (Clojure team)16:01:44

back up and state what problem you’re trying to solve

Alex Miller (Clojure team)16:01:21

tap is like prn - it is hard for me to meaningful say that either should have a “transducer form” or even what that means

mrchance16:01:56

Well, what I want is that I have a channel, which I want to distribute to different sinks, for which I currently use a mult and a few taps to the sink channels. That works quite well. Now I want to subject each of those connections to a different transducer for each sink, and I found no straightforward way to do that. What I meant by transducer form was something similar to pipeline, which as far as I know doesn't work on mults. I actually thought that pipe had a call signature with a transducer arg too, but apparently that's not the case

gordon16:01:21

can you supply a transducer to the sink channels? I'm sure I'm missing something...

mrchance16:01:23

No, it's a valid question, but I can not, because they are fed from different sources. Transforming everything to a common format is actually one of the reasons I need the transducers

fmjrey16:01:12

Not sure I understand the issue, tap does not take a transducer, but the channel you give it does...

Alex Miller (Clojure team)16:01:18

oh, hang on - you are talking about tap in core.async, not tap>, the new function in Clojure 1.10

Alex Miller (Clojure team)16:01:22

so completely ignore what I said before :)

Alex Miller (Clojure team)17:01:19

but, what fmjrey said - tap takes a channel, which can have a transducer applied to it

mrchance17:01:30

Ah! Did not know about the new tap 😉

mrchance17:01:05

Ok, so there is no straightforward solution, I have the sink channels provided to me and can not apply transducers to them afterwards

Alex Miller (Clojure team)17:01:45

you could connect new ones with pipe

gordon17:01:35

what you said about using pipe would work too, you supply your own transducer to the channel at the end of the pipe you control - that's where the "transducer arg" analog would be in your q above

mrchance17:01:50

ok, so I create a new channel with a transducer, tap into that, and pipe from there to the sink, did I understand that correctly?

gordon17:01:59

if that works for you, yes. it sounded just now like you weren't in control of the sink channels that got supplied to you, so that's the reason for using an additional channel that you do control, supplying a transducer to it when you create it, and hooking it/them up to the sink channel/s via pipe.

mrchance17:01:26

yeah, that'd work, will probably end up doing that, thanks all!

fmjrey17:01:30

Or maybe use transduce?

fmjrey17:01:35

sorry transduce reduces, ignore my comment