Currently Coyoneda uses function composition to join the inner function with a function we map over. The problem with this is that if you try to evaluate[1] a coyoneda value that has been mapped a lot of times you get a stack overflow.
This PR solves this issue by using a new Function1LazyComposition that keeps a type-erase list of functions that can be called one after the other.
This solution is similar to how Coyoneda was implemented in Bow before, and also how it is implemented in Scala, but Function1LazyComposition keeps track of what the input and output types of the composed function are.
Currently Coyoneda uses function composition to join the inner function with a function we map over. The problem with this is that if you try to evaluate[1] a coyoneda value that has been mapped a lot of times you get a stack overflow.
This PR solves this issue by using a new
Function1LazyComposition
that keeps a type-erase list of functions that can be called one after the other.This solution is similar to how Coyoneda was implemented in Bow before, and also how it is implemented in Scala, but
Function1LazyComposition
keeps track of what the input and output types of the composed function are.[1] For example when calling
lower()
orflatMap