I came across this thread because I have written a lot of stuff like consecutive Enum.map because it is usually cleaner. For example, I just did this in Advent of Code 2022:
round_strategies()
|> Enum.map(&convert_strategy_to_round/1)
|> Enum.map(&score_round/1)
A question I have is why does this need to be handled via a library, macros, or even syntax? Isn’t this really something the compiler could or should be doing as an optimization/fusion pass?
Why can’t the compiler see the above and fuse it to a single Enum.map by sequencing the mapper functions? (Disclaimer: I do not know how the Elixir compiler works, but it was my understanding that this is how this stuff can be done.)






















