如何为 GHCi 设置程序的命令行参数?
假设使用 Now 执行某个 Haskell 文件
runghc Queens.hs gecode_compile
,但失败了,我想使用 ghci 来调试它。如何将选项 gecode_compile
传递到程序中,以便 getArgs
能够正确读取它?
谢谢!!
Suppose some Haskell file is executed with
runghc Queens.hs gecode_compile
Now, this fails, and I want to debug it with ghci
. How do I pass the option gecode_compile
into the program, so getArgs
will read it correctly?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
中设置命令行参数
您还可以在 ghci或
You can also set the command line arguments in ghci
or
您可以使用
System.Environment.withArgs
函数使用所需的参数执行main
。这是一个示例会话(省略了不相关的细节):
You can use the
System.Environment.withArgs
function to executemain
with your desired arguments.Here's an example session (irrelevant details elided):
您可以使用
:set
命令:这意味着
getArgs
返回["whatever"]
。所以在你的情况下你应该这样做:
You can use the
:set
command:This will mean that
getArgs
returns["whatever"]
.So in your case you should just do this: