Fork me on GitHub
#clojure-europe
<
2020-10-16
>
slipset06:10:48

A guess all my talks are Assums?

slipset06:10:30

Oh, and good morning!

pez06:10:54

Morsning korsning!

genRaiy07:10:56

good, bright and crisp morning

genRaiy07:10:44

thanks to @borkdude and @mpenet for an eduction education this week

pez08:10:13

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.

orestis08:10:01

@pez the original talk is probably the most informative one: https://www.youtube.com/watch?v=6mTbuzafcII

❤️ 6
orestis08:10:28

The audio gets better after the first 10 seconds

dominicm09:10:03

I really loved Tim's transducer explanations. That's when it all clicked for me.

metal 3
3
pez10:10:50

I’ll need to decide what I need the most. Getting transducers to click for me or the money. 😃

dominicm10:10:04

Doesn't he have a free one where he explains the functions

pez11:10:13

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.

otfrom10:10:21

I mostly just use transducers where I would have used ->>

pez10:10:46

Ah, that's interesting! And very helpful for me. Thanks!

otfrom12:10:26

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 ->>

Ben Hammond10:10:11

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 thing

Ben Hammond10:10:53

I'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

borkdude10:10:42

@ben.hammond What's the catch? eductions can behave as iterable objects, but also as efficiently reducible objects.

Ben Hammond10:10:11

(clojure.lang.TransformerIterator/create xform (clojure.lang.RT/iter coll))
might blow up if coll is just an IReduceInit but not a sequential

Ben Hammond10:10:45

creates a little unexploded Exception to be passed around

borkdude10:10:49

good point. what's an example of a coll that's not a sequential, but does satisfy IReduceInit?

Ben Hammond10:10:31

well anything that you created using

(reify IReduceInit
for example

Ben Hammond10:10:31

but 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

borkdude10:10:35

reify does support implementing multiple protocols/interfaces, but I guess you could forget to implement both

Ben Hammond10:10:55

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

borkdude10:10:48

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. ...))

Ben Hammond10:10:34

and you could similiarly create (deftype EductionReduceOnly

Ben Hammond10:10:59

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)

thomas11:10:00

good moaning

🗿 3
Ben Hammond11:10:23

there seems to be missing an emoji for > moan is 😩 the closest we can get?

Ben Hammond11:10:29

which (interestingly) looks like a USB-C plug

🤯 6
thomas14:10:21

Maybe a picture of an English man pretending to be a French police officer?

pez15:10:53

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!

otfrom15:10:01

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

pez15:10:37

Yeah, while I do want to have transduce in my tool chest, the most important thing to me right now is to be able to read more Clojure code.

otfrom15:10:38

I do find that into and transduce help me to create and read more clojure code. It makes it easy to create composable transformation pipelines

👍 6