How to set a program's command line arguments for GHCi?

梦想与她 提交于 2019-12-02 17:28:10

You can also set the command line arguments in ghci

ghci> :set args foo bar
ghci> main

or

ghci> :main foo bar

You can use the System.Environment.withArgs function to execute main with your desired arguments.

Here's an example session (irrelevant details elided):

$ ghci
GHCi, version 7.0.3: http://www.haskell.org/ghc/  :? for help
Prelude> import System.Environment
Prelude System.Environment> let main = getArgs >>= mapM_ putStrLn
Prelude System.Environment> withArgs ["hello", "world"] main
hello
world

You can use the :set command:

Prelude> :set args whatever

This will mean that getArgs returns ["whatever"].

So in your case you should just do this:

Prelude> :set args gecode_compile
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!