[Haskell-cafe] Haskell maximum stack depth

Adrian Hey ahey at iee.org
Tue Jan 29 15:28:54 EST 2008


Neil Mitchell wrote:

> My claim is that "any program which needs to adjust the stack size has
> a laziness leak" - since I've made a universally quantified claim, a
> couple of real examples should blow it out of the water.

But people often deliberately introduce lazyness leaks for improved
efficency and in order to avoid space leaks.

http://haskell.org/pipermail/glasgow-haskell-users/2007-May/012467.html

Here there is essentially no difference between stackGobbler and
heapGobbler (they both use a stack), but in order to avoid a
"stack overflow" heapGobbler is tail recursive and explicitly
implements the stack as a reversed list accumulator, which then
has to be reversed at the end, so will burn twice as much heap
to get a result as stackGobbler (at least if we already know the
list has evaluated at least up to the point where it's tail get
chopped off).

Regards
--
Adrian Hey




More information about the Haskell-Cafe mailing list