I already found this question and the answers to it.
On the accepted answer you can see my comment about the solution. It doesn't seem to work for example for this function:
fiblist = 0 : 1 : (zipWith (+) fiblist (tail fiblist))
fib :: (Integral a) => a -> String
fib n
| n < 10000 = show (genericIndex fiblist n)
| otherwise = error "The number is too high and the calculation might freeze your machine."
It still renders the system unusable, even if I only give GHCI 256Mb Heap and 256Mb Stack space. For a simple call of length
(of an infinite list) it does work.
My question now is: What does the solution for all cases look like? (Is there one? If not, why not?)
Edit #1: Additional information
- OS: Xubuntu 14.04
- RAM: 4GB
- Exact command I used for GHCI:
stack ghci +RTS -M256m -K256m
GHC Version:
stack ghc -v
results in:Version 1.0.2, Git revision fa09a980d8bb3df88b2a9193cd9bf84cc6c419b3 (3084 commits) x86_64 ... (a lot of other stuff) ...