This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Trampolines to help with deep recursion.
version 1.0.1
license BSD3
native-modules False
elm-version 0.17.0 <= v < 0.19.0
Tag 1.0.1
Committed At 2016-10-07 21:30:09 UTC
elm-lang/core 4.0.0 <= v < 6.0.0 5.1.1




Popular JavaScript implementations do not perform any tail-call elimination, so recursive functions can cause a stack overflow if they go too deep. That said, the Elm compiler optimizes tail calls into loops for functions that call themselves, so most situations will just get optimized behind the scenes for you.

The compiler does not do anything for mutually tail-recursive functions though. If you find yourself needing that, you can use a trampoline. Trampolines make it possible to call functions recursively without growing the stack.

This strategy creates intermediate closures, which is very expensive in JavaScript, so use this library only when it is essential that you recurse deeply.