Skip to content
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

What to do about composition of Transducers? #1

Open
MasonProtter opened this issue Nov 18, 2024 · 0 comments
Open

What to do about composition of Transducers? #1

MasonProtter opened this issue Nov 18, 2024 · 0 comments

Comments

@MasonProtter
Copy link
Member

Originally you used to be able to write foldl(+, Filter(f) |> Map(g), itr) but this was deprecated and replaced with foldl(+ Filter(f) ⨟ Map(g), itr) where f ⨟ g means g ∘ f (also known as opcompose). This was changed for somewhat convincing ideological reasons, but it's also quite the usability pain. (ref JuliaFolds/Transducers.jl#67).

I am very tempted to re-enable the Map(f) |> Filter(g) pattern for composing transducers, or at the very least, find a suitable ascii replacement for .

Some ascii options I'm thinking of:

  • Bite the bullet and just do |>. This is quite nice especially because its familiar and does match the eduction syntax itr |> Filter(f) |> Map(g) which is equivalent to eduction(Filter(f) ⨟ Map(g), itr).
  • Maybe another ascii option would be & (i.e. Filter(iseven) & Map(sin) would read as "filter out even numbers and apply sin to them" but I'm sure at least some people would protest that this is a horrible pun that does not respect the semantics of Base.:(&). I kinda like this.
  • Another available ascii operator is -->, so we could have Filter(iseven) --> Map(sin) read as "filter out even numbers and then apply sin to them". I'm not a huge fan of this, but it does have the advantage of being an available unicode operator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant