[Haskell-cafe] Re: Diagnosing stack overflow

Joe Buehler aspam at cox.net
Fri Aug 17 10:32:27 EDT 2007


Matthew Brecknell wrote:

> The key point of the example is that foldl itself doesn't need any of
> the intermediate values of the accumulator, so these just build up into
> a deeply-nested unevaluated thunk. When print finally demands an
> integer, the run-time pushes a stack frame for each level of parentheses
> it enters as it tries to evaluate the thunk. Too many parentheses leads
> to a stack overflow. Of course, the solution to the example is to use

What is the point in building this huge thunk if it can't be evaluated
without a stack overflow?  Could the runtime do partial evaluation
to keep the thunk size down or would that cause semantic breakage?

Joe Buehler



More information about the Haskell-Cafe mailing list