We might want to provide a macro that removes the trailing map if it is unneeded. The use for it would be to make a for-comprehension style expression stack-safe, since flatMap can be (and often is) implemented in a stack-safe manner, but a map isn't. One such example is:
def loop: IO[Unit] =
for
_ <- putStrLn("fix this pls")
_ <- loop
yield ()
We might want to add a macro elimMap that would be used like so:
We might want to provide a macro that removes the trailing map if it is unneeded. The use for it would be to make a
for
-comprehension style expression stack-safe, sinceflatMap
can be (and often is) implemented in a stack-safe manner, but amap
isn't. One such example is:We might want to add a macro
elimMap
that would be used like so:That will remove the trailing map call if it is unnecessary and give an error (or warning) if the
map
changes the result.