clojure-europe

For people in Europe... or elsewhere... UGT https://indieweb.org/Universal_Greeting_Time
slipset 2020-10-16T06:39:48.008800Z

A guess all my talks are Assums?

slipset 2020-10-16T06:50:30.009Z

Oh, and good morning!

pez 2020-10-16T06:56:54.009500Z

Morsning korsning!

raymcdermott 2020-10-16T07:58:56.010Z

good, bright and crisp morning

raymcdermott 2020-10-16T07:59:44.011Z

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

pez 2020-10-16T08:04:13.014300Z

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.

orestis 2020-10-16T08:17:01.014800Z

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

❀️ 2
2020-10-16T08:17:09.015100Z

morning

orestis 2020-10-16T08:17:28.015200Z

The audio gets better after the first 10 seconds

ordnungswidrig 2020-10-16T09:04:10.015700Z

’allo!

dominicm 2020-10-16T09:56:03.016800Z

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

βž• 1
🀘 1
pez 2020-10-16T10:01:50.017Z

I’ll need to decide what I need the most. Getting transducers to click for me or the money. πŸ˜ƒ

2020-10-16T10:12:21.017600Z

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

borkdude 2020-10-16T10:14:33.017800Z

someone wrote a clj-kondo hook for that: https://github.com/borkdude/clj-kondo/issues/323#issuecomment-691247062

2
2020-10-16T10:30:11.020400Z

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

borkdude 2020-10-16T10:31:42.021100Z

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

2020-10-16T10:31:53.021200Z

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

2020-10-16T10:33:11.022300Z

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

2020-10-16T10:33:45.022900Z

creates a little unexploded Exception to be passed around

borkdude 2020-10-16T10:33:49.023100Z

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

2020-10-16T10:34:31.024Z

well anything that you created using

(reify IReduceInit
for example

2020-10-16T10:36:31.025600Z

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

borkdude 2020-10-16T10:36:35.025700Z

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

2020-10-16T10:37:55.027300Z

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

borkdude 2020-10-16T10:38:48.028400Z

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

2020-10-16T10:39:34.029Z

and you could similiarly create (deftype EductionReduceOnly

2020-10-16T10:40:59.030700Z

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)

pez 2020-10-16T10:52:46.031300Z

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

dominicm 2020-10-16T10:58:04.031600Z

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

thomas 2020-10-16T11:16:00.032Z

good moaning

πŸ—Ώ 1
2020-10-16T11:26:23.033Z

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

2020-10-16T11:26:58.033200Z

maybe 😬

2020-10-16T11:27:29.033800Z

which (interestingly) looks like a USB-C plug

🀯 2
pez 2020-10-16T11:31:13.033900Z

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.

2020-10-16T12:20:26.034100Z

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

thomas 2020-10-16T14:07:21.035200Z

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

pez 2020-10-16T15:14:53.036900Z

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!

2020-10-16T15:18:25.037100Z

πŸ™‚

2020-10-16T15:19:01.037800Z

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

pez 2020-10-16T15:22:37.039600Z

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.

2020-10-16T15:28:38.040400Z

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

πŸ‘ 2