如何传递堆栈 ghci RTS 选项?

How to pass stack ghci RTS options?

我正在寻找类似

的东西
$ stack ghci -- Main.hs +RTS -M20M
Cannot use 'stack ghci' with both file targets and build targets

由于不推荐此解决方法(为什么?):

stack exec -- ghci Main.hs +RTS -M20M

啊,这确实是一个非常糟糕的错误信息。我为此创建了一个问题 - https://github.com/commercialhaskell/stack/issues/3342 - 并实施了修复,以便堆栈的下一个版本将改为说

The following errors occurred while parsing the build targets: - Directory not found: +RTS - Directory not found: -M20M

Note that to specify options to be passed to GHCi, use the --ghci-options flag

相反 运行 stack ghci Main.hs --ghci-options '+RTS -M20M' 释放堆栈将产生:

ghc: unknown RTS option: -ghci-script=/tmp/ghci29580/ghci-script

因为用户参数没有传递到最后。我也修好了。现在,您可以使用 stack ghci Main.hs --ghci-options '+RTS -M20M -RTS'