Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transducers #41

Closed
lilactown opened this issue Aug 18, 2022 · 0 comments
Closed

Transducers #41

lilactown opened this issue Aug 18, 2022 · 0 comments

Comments

@lilactown
Copy link
Collaborator

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:

  1. Programming errors emerge that aren't caught by simple arity checking, e.g. (first (map inc))
  2. 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 map filter 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.

Feedback welcome!

This was referenced Aug 26, 2022
@squint-cljs squint-cljs locked and limited conversation to collaborators Aug 29, 2022
@borkdude borkdude converted this issue into discussion #179 Aug 29, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant