From: Ian Lynagh Date: Sun, 3 Sep 2006 22:31:07 +0000 (+0000) Subject: Add :main docs to ghci commands page X-Git-Tag: Before_FC_branch_merge~81 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=e38496fa2f7b8d7f6541677ac91149562f6f19ae Add :main docs to ghci commands page --- diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 26efdee..e53c7c6 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -1072,6 +1072,38 @@ Prelude> :. cmds.ghci + :main arg1 ... argn + :main + + + + 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"] + + + + + + + :module +|- *mod1 ... *modn :module