Commit e38496fa authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Add :main docs to ghci commands page

parent 8eb677bc
...@@ -1070,6 +1070,38 @@ Prelude> :. cmds.ghci ...@@ -1070,6 +1070,38 @@ Prelude> :. cmds.ghci
</listitem> </listitem>
</varlistentry> </varlistentry>
<literal>:main <replaceable>arg<subscript>1</subscript></replaceable> ... <replaceable>arg<subscript>n</subscript></replaceable></literal>
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
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,
Prelude> let main = System.Environment.getArgs >>= print
Prelude> :main foo bar
<varlistentry> <varlistentry>
<term> <term>
<literal>:module <optional>+|-</optional> <optional>*</optional><replaceable>mod<subscript>1</subscript></replaceable> ... <optional>*</optional><replaceable>mod<subscript>n</subscript></replaceable></literal> <literal>:module <optional>+|-</optional> <optional>*</optional><replaceable>mod<subscript>1</subscript></replaceable> ... <optional>*</optional><replaceable>mod<subscript>n</subscript></replaceable></literal>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment