[project @ 2002-01-08 14:11:28 by sof]
[ghc-hetmet.git] / ghc / docs / users_guide / ghci.sgml
index a82782f..87f2944 100644 (file)
@@ -150,6 +150,21 @@ Main> fac 17
       in the same directory and you can't call them all
       <filename>Main.hs</filename>.</para>
 
+      <para>The search path for finding source files is specified with
+      the <option>-i</option> option on the GHCi command line, like
+      so:</para>
+<screen>ghci -i<replaceable>dir<subscript>1</subscript></replaceable>:...:<replaceable>dir<subscript>n</subscript></replaceable></screen>
+
+      <para>or it can be set using the <literal>:set</literal> command
+      from within GHCi (see <xref
+      linkend="ghci-cmd-line-options">)<footnote><para>Note that in
+      GHCi, and <option>&ndash;&ndash;make</option> mode, the <option>-i</option>
+      option is used to specify the search path for
+      <emphasis>source</emphasis> files, whereas in standard
+      batch-compilation mode the <option>-i</option> option is used to
+      specify the search path for interface files, see <xref
+      linkend="options-finding-imports">.</para> </footnote></para>
+
       <para>One consequence of the way that GHCi follows dependencies
       to find modules to load is that every module must have a source
       file.  The only exception to the rule is modules that come from
@@ -290,7 +305,7 @@ Ok, modules loaded: A, B, C, D.
     <para>HINT: since GHCi will only use a compiled object file if it
     can sure that the compiled version is up-to-date, a good technique
     when working on a large program is to occasionally run
-    <literal>ghc --make</literal> to compile the whole project (say
+    <literal>ghc &ndash;&ndash;make</literal> to compile the whole project (say
     before you go for lunch :-), then continue working in the
     interpreter.  As you modify code, the new modules will be
     interpreted, but the rest of the project will remain
@@ -528,10 +543,10 @@ Wed Mar 14 12:23:13 GMT 2001
   <sect1 id="ghci-invokation">
     <title>Invoking GHCi</title>
     <indexterm><primary>invoking</primary><secondary>GHCi</secondary></indexterm>
-    <indexterm><primary><option>--interactive</option></primary></indexterm>
+    <indexterm><primary><option>&ndash;&ndash;interactive</option></primary></indexterm>
 
     <para>GHCi is invoked with the command <literal>ghci</literal> or
-    <literal>ghc --interactive</literal>.  One or more modules or
+    <literal>ghc &ndash;&ndash;interactive</literal>.  One or more modules or
     filenames can also be specified on the command line; this
     instructs GHCi to load the specified modules or filenames (and all
     the modules they depend on), just as if you had said
@@ -713,11 +728,11 @@ Prelude> :mycd ..
 </screen>
 
          <para>Or I could define a simple way to invoke
-         &ldquo;<literal>ghc --make Main</literal>&rdquo; in the
+         &ldquo;<literal>ghc &ndash;&ndash;make Main</literal>&rdquo; in the
          current directory:</para>
 
 <screen>
-Prelude> :def make (\_ -> return ":! ghc --make Main")
+Prelude> :def make (\_ -> return ":! ghc &ndash;&ndash;make Main")
 </screen>
 
        </listitem>
@@ -942,7 +957,7 @@ Prelude> :def make (\_ -> return ":! ghc --make Main")
       </variablelist>
     </sect2>
 
-    <sect2>
+    <sect2 id="ghci-cmd-line-options">
       <title>Setting GHC command-line options in GHCi</title>
 
       <para>Normal GHC command-line options may also be set using
@@ -1109,8 +1124,31 @@ Prelude> :set -fno-glasgow-exts
          properly with GHC's concurrency model.</para>
        </listitem>
       </varlistentry>
-    </variablelist>
 
+      <varlistentry>
+       <term>After using <literal>getContents</literal>, I can't use
+       <literal>stdin</literal> again until I do
+       <literal>:load</literal> or <literal>:reload</literal>.</term>
+
+       <listitem>
+         <para>This is the defined behaviour of
+         <literal>getContents</literal>: it puts the stdin Handle in
+         a state known as <firstterm>semi-closed</firstterm>, wherein
+         any further I/O operations on it are forbidden.  Because I/O
+         state is retained between computations, the semi-closed
+         state persists until the next <literal>:load</literal> or
+         <literal>:reload</literal> command.</para>
+
+         <para>You can make <literal>stdin</literal> reset itself
+         after every evaluation by giving GHCi the command
+         <literal>:set +r</literal>.  This works because
+         <literal>stdin</literal> is just a top-level expression that
+         can be reverted to its unevaluated state in the same way as
+         any other top-level expression (CAF).</para>
+       </listitem>
+      </varlistentry>
+
+    </variablelist>
   </sect1>
 
 </chapter>