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
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) ...
stack ghci +RTS -M256m -K256m
That's not setting the RTS options of GHCi, but stack
. After all, stack
is also written in Haskell and therefore can take RTS options too.
Use --ghci-options
to provide additional options to GHCi instead:
stack ghci --ghci-options="+RTS -M256m -K256m -RTS"
The closing -RTS
is necessary since stack
provides some more options to GHCi.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With