[project @ 2001-10-02 11:09:55 by simonmar]
[ghc-hetmet.git] / ghc / docs / users_guide / ghci.sgml
index 6c65538..3e900c4 100644 (file)
@@ -525,7 +525,7 @@ Wed Mar 14 12:23:13 GMT 2001
     </sect2>
   </sect1>
 
-  <sect1>
+  <sect1 id="ghci-invokation">
     <title>Invoking GHCi</title>
     <indexterm><primary>invoking</primary><secondary>GHCi</secondary></indexterm>
     <indexterm><primary><option>--interactive</option></primary></indexterm>
@@ -1109,8 +1109,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>