From e38496fa2f7b8d7f6541677ac91149562f6f19ae Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sun, 3 Sep 2006 22:31:07 +0000 Subject: [PATCH] Add :main docs to ghci commands page --- docs/users_guide/ghci.xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 -- 1.7.10.4