You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating a long chain of and_then calls to the same monad can in theory overflow the stack. The common solution to this problem is trampolines.
I'm not sure how big a of a problem this will be in practice, since I think combining imperative style with functional style can in many cases alleviate the problem (see e.g the implementation of util.sequence_.)
Edit:
It will be a big problem.
The text was updated successfully, but these errors were encountered:
suned
changed the title
Trampolines
Trampolines (or some other way of avoiding RecursionError on long compositions of Readers and Writers)
Sep 13, 2019
suned
changed the title
Trampolines (or some other way of avoiding RecursionError on long compositions of Readers and Writers)
Trampolines (or some other way of avoiding RecursionError on long compositions of Reader or State)
Sep 13, 2019
Did a first (failed) attempt in /suned/pfun/experiment/trampolines. Main challenge is that python does not support tail call optimisation what so ever. There are multiple hacks for self tail calls, but so far no luck in making it work with e.g State. I think the problem is that the recursion involves a number of intermediate calls that are not part of the mutual recursion.
One other interesting idea is to implement the recursive structures in C since gcc supports tail call optimisation. Cython may be an option, but its unclear whether the compiled code will be tail recursive.
Creating a long chain of
and_then
calls to the same monad can in theory overflow the stack. The common solution to this problem is trampolines.I'm not sure how big a of a problem this will be in practice, since I think combining imperative style with functional style can in many cases alleviate the problem (see e.g the implementation of
util.sequence_
.)Edit:
It will be a big problem.
The text was updated successfully, but these errors were encountered: