This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-16
Channels
- # announcements (5)
- # asami (4)
- # babashka (72)
- # beginners (241)
- # calva (15)
- # cider (2)
- # circleci (5)
- # clara (41)
- # clj-kondo (38)
- # cljsrn (4)
- # clojars (33)
- # clojure (283)
- # clojure-europe (41)
- # clojure-nl (9)
- # clojure-uk (11)
- # clojuredesign-podcast (14)
- # clojurescript (76)
- # conjure (12)
- # cryogen (42)
- # data-science (1)
- # datalog (6)
- # datomic (7)
- # depstar (10)
- # events (2)
- # figwheel-main (1)
- # fulcro (22)
- # funcool (1)
- # london-clojurians (1)
- # malli (8)
- # meander (11)
- # off-topic (12)
- # pathom (19)
- # re-frame (8)
- # reveal (34)
- # shadow-cljs (34)
- # sql (7)
- # vim (8)
- # xtdb (6)
good, bright and crisp morning
thanks to @borkdude and @mpenet for an eduction education this week
So with @borkdude’s and @slipset’s help I sort of get some of the rationale for transducers. Still need to understand the mechanics. I found the first course in a series about transducers by Tim Baldridge. But it didn't even reach the point where a transducer was used. 😃 I'll check that reference page out first and see where that lands me.
@pez the original talk is probably the most informative one: https://www.youtube.com/watch?v=6mTbuzafcII
’allo!
I really loved Tim's transducer explanations. That's when it all clicked for me.

I’ll need to decide what I need the most. Getting transducers to click for me or the money. 😃
Not sure which functions? I found a fee one where he starts to talk about transducers, but the rest of that series is not free.
yeah, most of the talks early on just confused me as they talked a lot about the internals of transducers, whereas what I needed to know was that they were faster, created less garbage, and could replace most of my ->>
someone wrote a clj-kondo hook for that: https://github.com/borkdude/clj-kondo/issues/323#issuecomment-691247062

I always worry that there is a lurking problem with eductions
(deftype Eduction [xform coll]
Iterable
...
clojure.lang.IReduceInit
...
clojure.lang.Sequential)
in that Iterable
is supposed to give you an infinite number of usable Iterator
objects, but IReduceInit
does not provide that kind of implication; it might just be a one-shot thingI've see eductions used where you pass in a reducible as the coll
, but then other parts see the Iterable
interface flaunted by the eduction, try to use it as a sequential, and wonder why it oges horribly wrong
@ben.hammond What's the catch? eductions can behave as iterable objects, but also as efficiently reducible objects.
(clojure.lang.TransformerIterator/create xform (clojure.lang.RT/iter coll))
might blow up if coll
is just an IReduceInit
but not a sequentialcreates a little unexploded Exception to be passed around
good point. what's an example of a coll that's not a sequential, but does satisfy IReduceInit?
well anything that you created using
(reify IReduceInit
for examplebut I'm conflating two seperate issue here
• Don't create eduction with colls that do not support Iterable
is not the same as
• How do you distinguish IReduceInits
that are reusable from those that are one-shot
reify does support implementing multiple protocols/interfaces, but I guess you could forget to implement both
I worked on a project where we had a Cognitect consultant who did exactly this; it creates an issue because when their Clojure-fu so far outstrips the team's it takes quite a while to figure out the problem
I guess you could also implement your own type on top of IReduceInit:
(deftype OneShot [xforms coll] IreduceInit ...)
which you can then feed to (into [] (OneShot. ...))
and you could similiarly create (deftype EductionReduceOnly
problem comes in when the logging framework
• sees the Sequential
on the eduction
tries to use it to write a log string an blows up your server
OR
• correctly uses the one-shot IReduceInit
, but thus exhausts the reducible so its not available to do the real work
(for example, all sorts of insidious problems can arise from this)
there seems to be missing an emoji for > moan is 😩 the closest we can get?
maybe 😬
Ha! I've now rewritten a few transduce
examples to ->>
. A bit backward, you might think, but it seems to help me figure out how to use transduce
. Thanks @otfrom!
I think I probably use into
more than transduce
, but I usually just want to do something horrible to a seq and have it turn into a vector