From 77b441f2bbc4a1cc27d097e6e4fbf09425387a83 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sun, 3 Sep 2006 22:01:30 +0000 Subject: [PATCH] Add docs for :main --- docs/users_guide/ghci.xml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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"] + + + -- 1.7.10.4