Adding TcGadt.lhs
[ghc-hetmet.git] / docs / users_guide / ghci.xml
index edc3e22..9ec07c3 100644 (file)
@@ -604,6 +604,12 @@ Prelude IO>
       behaves in the same way for expressions typed at the
       prompt.</para>
 
+      <para>
+        Hint: GHCi will tab-complete names that are in scope; for
+        example, if you run GHCi and type <literal>J&lt;tab&gt;</literal>
+        then GHCi will expand it to <literal>Just </literal>.
+      </para>
+
       <sect3>
        <title>Qualified names</title>
 
@@ -792,22 +798,15 @@ $ ghci Main.hs
       package be loaded by using the <literal>-package</literal> flag:</para>
 
 <screen>
-$ ghci -package data
+$ ghci -package readline
    ___         ___ _
   / _ \ /\  /\/ __(_)
- / /_\// /_/ / /  | |      GHC Interactive, version 5.05, for Haskell 98.
+ / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
 / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
 \____/\/ /_/\____/|_|      Type :? for help.
 
 Loading package base ... linking ... done.
-Loading package haskell98 ... linking ... done.
-Loading package lang ... linking ... done.
-Loading package concurrent ... linking ... done.
-Loading package readline ... linking ... done.
-Loading package unix ... linking ... done.
-Loading package posix ... linking ... done.
-Loading package util ... linking ... done.
-Loading package data ... linking ... done.
+Loading package readline-1.0 ... linking ... done.
 Prelude> 
 </screen>
 
@@ -880,10 +879,8 @@ $ ghci -lm
     <para>GHCi commands all begin with
     &lsquo;<literal>:</literal>&rsquo; and consist of a single command
     name followed by zero or more parameters.  The command name may be
-    abbreviated, as long as the abbreviation is not ambiguous.  All of
-    the builtin commands, with the exception of
-    <literal>:unset</literal> and <literal>:undef</literal>, may be
-    abbreviated to a single letter.</para>
+    abbreviated, with ambiguities being resolved in favour of the more
+    commonly used commands.</para>
 
     <variablelist>
       <varlistentry>
@@ -1081,6 +1078,38 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
+          <literal>:main <replaceable>arg<subscript>1</subscript></replaceable> ... <replaceable>arg<subscript>n</subscript></replaceable></literal>
+          <indexterm><primary><literal>:main</literal></primary></indexterm>
+        </term>
+        <listitem>
+          <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>
+
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:module <optional>+|-</optional> <optional>*</optional><replaceable>mod<subscript>1</subscript></replaceable> ... <optional>*</optional><replaceable>mod<subscript>n</subscript></replaceable></literal>
           <indexterm><primary><literal>:module</literal></primary></indexterm>
         </term>