Lazy Evaluation's TCO Challenge: The Space Leak

While TCO prevents stack overflow, Haskell's lazy evaluation can lead to 'space leaks,' where unevaluated expressions (thunks) accumulate on the heap, consuming excessive memory. This occurs because the recursive call might be in tail position, but the *arguments* to that call are not fully evaluated, creating a chain of thunks instead of a single value.

Sources

Open the full topic