[Haskell-cafe] Haskell maximum stack depth

Neil Mitchell ndmitchell at gmail.com
Mon Jan 28 10:28:26 EST 2008


Hi Istarex,

> Does Haskell have a maximum stack depth restriction like Java &
> Python, or is it only limited by the maximum stack available on the
> system (i.e. what would be available to a C program)?

You are probably thinking that recursive functions use up program
stack, and hence the stack depth bounds the amount of recursion. In
Haskell, that isn't the case. Haskell is lazily evaluated, and has
tail recursion, which means that you rarely run into a problem with
exceeding the stack depth. In GHC the "stack" is stored in the heap
area of memory, so is not limited to the C stack, but can be set at
runtime with a flag (+RTS ... something ...) - but you won't need to.

Thanks

Neil


More information about the Haskell-Cafe mailing list