You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Clojure, transducers are created by calling core seq functions without the collection, e.g. (map inc), (filter even?). While convenient (no new names needed, no new requires needed), it also adds a couple of challenges:
Programming errors emerge that aren't caught by simple arity checking, e.g. (first (map inc))
Transducer code can't be tree shaken if one uses (map inc coll)
The first can be caught by better static analysis (clj-kondo) but the second is hard for existing tooling to do.
I proposed two different provocative solutions in slack:
what if we only had transducers, and eschewed mapfilter with the collection passed in?
what if we moved transducers to its own namespace?
Initial response to the first was that it would be too unfamiliar to people coming from Clojure(Script), but that the second would be a good one to try.
Proposal
We add a new namespace, clava.transducers which would hold the transducer protocol and transducing functions.
Transducers would be objects that satisfy the transformer protocol, allowing them to interop with other libraries like Ramda.
We could build it in JS, however I'm interested in trying to build it in Clava source. This would necessarily force us to build and exercise #21.
This discussion was converted from issue #41 on August 29, 2022 10:06.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Background
Moving this from slack to an issue.
In Clojure, transducers are created by calling core seq functions without the collection, e.g.
(map inc)
,(filter even?)
. While convenient (no new names needed, no new requires needed), it also adds a couple of challenges:(first (map inc))
(map inc coll)
The first can be caught by better static analysis (clj-kondo) but the second is hard for existing tooling to do.
I proposed two different provocative solutions in slack:
map
filter
with the collection passed in?Initial response to the first was that it would be too unfamiliar to people coming from Clojure(Script), but that the second would be a good one to try.
Proposal
We add a new namespace,
clava.transducers
which would hold the transducer protocol and transducing functions.Transducers would be objects that satisfy the transformer protocol, allowing them to interop with other libraries like Ramda.
We could build it in JS, however I'm interested in trying to build it in Clava source. This would necessarily force us to build and exercise #21.
Feedback welcome!
Beta Was this translation helpful? Give feedback.
All reactions