More output updates
[ghc-hetmet.git] / docs / users_guide / ghci.xml
index de56c72..e79fb46 100644 (file)
@@ -561,9 +561,9 @@ Compiling Main             ( Main.hs, interpreted )
 
 <screen>
 Prelude> :module +IO
-Prelude,IO> hPutStrLn stdout "hello\n"
+Prelude IO> hPutStrLn stdout "hello\n"
 hello
-Prelude,IO>
+Prelude IO>
 </screen>
 
       <para>(Note: <literal>:module</literal> can be shortened to
@@ -593,7 +593,7 @@ Prelude,IO>
       <literal>Bar</literal>, then the scope will be set to
       <literal>*Bar</literal> if <literal>Bar</literal> is
       interpreted, or if <literal>Bar</literal> is compiled it will be
-      set to <literal>Prelude,Bar</literal> (GHCi automatically adds
+      set to <literal>Prelude Bar</literal> (GHCi automatically adds
       <literal>Prelude</literal> if it isn't present and there aren't
       any <literal>*</literal>-form modules).</para>
 
@@ -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>
   
 
@@ -633,9 +661,9 @@ Prelude> it * 2
     expression, and if it doesn't have an <literal>IO</literal> type,
     then it transforms it as follows: an expression
     <replaceable>e</replaceable> turns into 
-<screen>     
-             let it = <replaceable>e</replaceable>;
-             print it
+<screen>
+let it = <replaceable>e</replaceable>;
+print it
 </screen>
     which is then run as an IO-action.</para>
 
@@ -644,10 +672,14 @@ Prelude> it * 2
     complain:</para>
 
 <screen>
-Prelude> id
-No instance for `Show (a -> a)'
-arising from use of `print'
-in a `do' expression pattern binding: print it
+Prelude&gt; id
+
+&lt;interactive&gt;:1:0:
+    No instance for (Show (a -&gt; a))
+      arising from use of `print' at &lt;interactive&gt;:1:0-1
+    Possible fix: add an instance declaration for (Show (a -> a))
+    In the expression: print it
+    In a 'do' expression: print it
 </screen>
 
     <para>The error message contains some clues as to the
@@ -659,14 +691,15 @@ in a `do' expression pattern binding: print it
       which is of type <literal>a</literal>.  eg.:</para>
 <screen>
 Prelude> Time.getClockTime
+Wed Mar 14 12:23:13 GMT 2001
 Prelude> print it
 Wed Mar 14 12:23:13 GMT 2001
 </screen>
 
       <para>The corresponding translation for an IO-typed
       <replaceable>e</replaceable> is
-<screen>     
-             it &lt;- <replaceable>e</replaceable>
+<screen>
+it &lt;- <replaceable>e</replaceable>
 </screen>
       </para>
 
@@ -759,22 +792,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>