From: Ian Lynagh Date: Sun, 3 Sep 2006 22:01:30 +0000 (+0000) Subject: Add docs for :main X-Git-Tag: Before_FC_branch_merge~84 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=77b441f2bbc4a1cc27d097e6e4fbf09425387a83;p=ghc-hetmet.git Add docs for :main --- diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 929e9dd..edc3e22 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -612,6 +612,34 @@ Prelude IO> qualified declaration for every module in every package, and every module currently loaded into GHCi. + + + The <literal>:main</literal> command + + + When a program is compiled and executed, it can use the + getArgs function to access the + command-line arguments. + However, we cannot simply pass the arguments to the + main function while we are testing in ghci, + as the main function doesn't take its + directly. + + + + Instead, we can use the :main command. + This runs whatever main is in scope, with + any arguments being treated the same as command-line arguments, + e.g.: + + + +Prelude> let main = System.Environment.getArgs >>= print +Prelude> :main foo bar +["foo","bar"] + + +