[Haskell-cafe] Diagnose stack space overflow

Ketil Malde ketil at malde.org
Fri Jul 8 11:34:16 CEST 2011


John Lato <jwlato at gmail.com> writes:

>> I want to find out the culprit function and rewrite it tail-recursively. Is
>> there a way to find out which function is causing this error other
>> than reviewing the code manually?

> I'd like to point out that a stack-space overflow in Haskell isn't quite the
> same thing as in other functional languages.  In particular, it's possible
> for tail-recursive functions to overflow the stack because of laziness.

..in fact, you often want to *avoid* tail recursion (e.g. as implemented in
foldl) and use something that is not tail recursive (e.g. foldr) but
more laziness-friendly.  Or use strictness (foldl').

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants



More information about the Haskell-Cafe mailing list