Zel*_*ahl 4 memory haskell ghci haskell-stack
我已经找到了这个问题及其答案.
在接受的答案上,您可以看到我对该解决方案的评论.它似乎不适用于此功能:
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."
它仍然使系统无法使用,即使我只提供GHCI 256Mb堆和256Mb堆栈空间.对于length(无限列表)的简单调用,它确实有效.
我现在的问题是:所有案例的解决方案是什么样的?(有吗?如果没有,为什么不呢?)
编辑#1:其他信息
stack ghci +RTS -M256m -K256mGHC版本:stack ghc -v结果:
Version 1.0.2, Git revision fa09a980d8bb3df88b2a9193cd9bf84cc6c419b3 (3084 commits) x86_64
... (a lot of other stuff) ...
Run Code Online (Sandbox Code Playgroud)stack ghci +RTS -M256m -K256m
那不是设置GHCi的RTS选项,而是stack.毕竟,stack也是用Haskell编写的,因此也可以使用RTS选项.
用于--ghci-options为GHCi提供其他选项:
stack ghci --ghci-options="+RTS -M256m -K256m -RTS"
结束-RTS是必要的,因为stackGHCi提供了更多的选择.