Skip to content

What to do about composition of Transducers?  #1

@MasonProtter

Description

@MasonProtter

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions