diff options
author | Ian Lynagh <igloo@earth.li> | 2006-09-03 22:01:30 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2006-09-03 22:01:30 +0000 |
commit | 77b441f2bbc4a1cc27d097e6e4fbf09425387a83 (patch) | |
tree | 1b444fac1b09bd3a59d8475024d49e3d26edefbd | |
parent | 0583778f773db20f20c547aa67abe59dfc77b875 (diff) | |
download | haskell-77b441f2bbc4a1cc27d097e6e4fbf09425387a83.tar.gz |
Add docs for :main
-rw-r--r-- | docs/users_guide/ghci.xml | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 929e9dd376..edc3e22141 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -612,6 +612,34 @@ Prelude IO> qualified</literal> declaration for every module in every package, and every module currently loaded into GHCi.</para> </sect3> + + <sect3> + <title>The <literal>:main</literal> command</title> + + <para> + When a program is compiled and executed, it can use the + <literal>getArgs</literal> function to access the + command-line arguments. + However, we cannot simply pass the arguments to the + <literal>main</literal> function while we are testing in ghci, + as the <literal>main</literal> function doesn't take its + directly. + </para> + + <para> + Instead, we can use the <literal>:main</literal> command. + This runs whatever <literal>main</literal> is in scope, with + any arguments being treated the same as command-line arguments, + e.g.: + </para> + +<screen> +Prelude> let main = System.Environment.getArgs >>= print +Prelude> :main foo bar +["foo","bar"] +</screen> + + </sect3> </sect2> |