clj-kondo

imre 2025-02-21T22:17:48.380809Z

Just published a small config "lib" using the recent extensions to discouraged-var and min-clj-kondo-version: https://github.com/imrekoszo/unlazy

๐ŸŽ‰ 7
valerauko 2025-02-22T08:38:19.237879Z

As for mapv's high arities would (into [] (map ...) ...) work?

imre 2025-02-22T08:42:02.221149Z

Sadly, no. The only transducing context I know of that can use a multi-coll map is sequence, which produces a lazy seq. I meant to post an ask.clojure about this for a long time now

imre 2025-02-22T08:43:33.744979Z

But if you know about one then let me know!

imre 2025-02-22T09:47:20.674649Z

Prs are also welcome.

souenzzo 2025-02-23T01:32:05.729129Z

nice repo! Some extra lazy functions: sequence, eduction, seque Other functions like zipmap are "as lazy as mapv" Functions like tree-seq are also lazy, but it does not have a eager alternative

imre 2025-02-24T18:29:24.700319Z

looked further into zipmap and it uses seq which can be lazy

imre 2025-02-24T18:29:29.800989Z

๐Ÿ˜•

2025-02-24T18:30:13.172599Z

zipmap's algorithm isn't lazy, but it can accept lazy sequences

imre 2025-02-24T18:31:19.652709Z

gonna need to write that ask.clojure sometime ๐Ÿ™‚

2025-02-24T18:31:52.798419Z

user=> (zipmap [:a :b :c] (range))
{:a 0, :b 1, :c 2}

2025-02-24T18:32:23.571669Z

range is lazy, a vector literal isn't, the return value of zipmap isn't a lazy sequence

imre 2025-02-24T18:32:41.291329Z

yeah, that's clear

imre 2025-02-24T18:38:02.982949Z

So I think it turns something like this (zipmap [:a :b :c] (eduction (map inc) [1 2 3 4])) lazy internally

2025-02-24T18:38:26.138979Z

you're looking to avoid internal usage of lazy sequences even when the the output is strict?

imre 2025-02-24T18:39:24.905959Z

In an ideal scenario I'd want to avoid that yes

2025-02-24T18:41:36.051099Z

that's a much taller ask than "avoid lazyseq-producing functions" lol

imre 2025-02-24T18:41:41.713809Z

๐Ÿ˜„

imre 2025-02-24T18:42:56.140949Z

> I think transducers are a fundamental primitive that decouples critical logic from list/sequence processing and construction, and if I had Clojure to do all over I would put them at the bottom. > R.H.

2025-02-21T22:33:46.393329Z

this is really cool

imre 2025-02-21T22:38:32.216749Z

Thanks! What's even cooler is that it can be done with just a config file and a deps.edn!

2025-02-21T22:50:30.077589Z

right, it's honestly remarkable

imre 2025-02-23T10:41:48.781969Z

Thanks for the tips! Some thoughts: sequence is my approved gate from transducerland to lazyland, when thereโ€™s a need. eduction isnโ€™t lazy in the lazy seq overhead sense, I like it when I need to produce an intermediate iterable which will be consumed (once) entirely in a subsequent step. I have never used seque but it appears a rather specialized utility function to alter the observable behavior of an already lazy sequence, which I find justifiable. zipmap doesn't appear to be lazy to me per https://github.com/clojure/clojure/blob/clojure-1.12.0/src/clj/clojure/core.clj#L6660, am I missing something? tree-seq is a good one. There's a https://github.com/cgrand/xforms/issues/20 for a transducing version of it, it seems. Might be a good idea to revive it.