News for hackers. Stuff that matters.
Re:Clojure transducers from the ground up: using them in pra... by twic on Sunday October 29, 2017 @05:21PM (#15581475)
So are transducers basically this Java, but in Clojure:

https://gist.github.com/tomwhoiscontrary/e41d52e9c98a706552b...

?

I've done that in terms of Consumer, but it might also be possible, and perhaps more elegant, in terms of flat-mapping functions (Function<T, Stream<T>>).

If i've understood right, then from a Java point of view, transducers are an attempt to reify the various operations on streams - mapping, filtering, etc. To do that, you have to figure out a type which is general enough to model all those operations.

The need for a general type is where you get the perilously-close-to-general-abstract-nonsense "a transducer is a transformation from one reducing function to another". Here, "a reducing function" is what stands in, in a very oblique way, for the stream - it's ultimately a conduit for values, and transducers take some existing conduit, wrap another layer of processing round it, and give you the resulting conduit. So they're a bit like backward streams, i suppose. If anything, it's like how you go around wrapping up layers of OutputStreams when doing IO:

  new PrintStream(new BufferedOutputStream(new GZIPOutputStream(new CipherOutputStream(new FileOutputStream("file.dat"), cipher))));
Except instead of explicitly constructing wrappers, transducers know how to do the wrapping.
Re:Clojure transducers from the ground up: using them in pra... by phaedrus on Monday October 30, 2017 @12:29PM (#15586352)
I thought that transducers also abstracted away the difference between an input stream and an output stream? (Or the difference between pulling values on demand versus pushing values.)