fix for gcc 4.1.x
[ghc-hetmet.git] / ghc / docs / users_guide / ghci.xml
index a0210ea..786815d 100644 (file)
@@ -59,10 +59,13 @@ Prelude>
    :set <option> ...          set options
    :set args <arg> ...        set the arguments returned by System.getArgs
    :set prog <progname>       set the value returned by System.getProgName
-
+   :set prompt <prompt>       set the prompt used in GHCi
    :show modules              show the currently loaded modules
    :show bindings             show the current bindings made at the prompt
 
+   :ctags [<file>]            create tags file for Vi (default: "tags")
+   :etags [<file>]            create tags file for Emacs (defauilt: "TAGS")
    :type <expr>               show the type of <expr>
    :kind <type>               show the kind of <type>
    :undef <cmd>               undefine user-defined command :<cmd>
@@ -428,16 +431,30 @@ Prelude>
       <literal>x</literal> in future statements, for example to print
       it as we did above.</para>
 
+      <para>GHCi will print the result of a statement if and only if: 
+       <itemizedlist>
+         <listitem>
+           <para>The statement is not a binding, or it is a monadic binding 
+             (<literal>p &lt;- e</literal>) that binds exactly one
+             variable.</para>
+         </listitem>
+         <listitem>
+           <para>The variable's type is not polymorphic, is not
+             <literal>()</literal>, and is an instance of
+             <literal>Show</literal></para>
+         </listitem>
+       </itemizedlist>
+      </para>
+
       <para>Of course, you can also bind normal non-IO expressions
       using the <literal>let</literal>-statement:</para>
 <screen>
 Prelude> let x = 42
-42
-Prelude> print x
+Prelude> x
 42
 Prelude>
 </screen>
-      <para>An important difference between the two types of binding
+      <para>Another important difference between the two types of binding
       is that the monadic bind (<literal>p &lt;- e</literal>) is
       <emphasis>strict</emphasis> (it evaluates <literal>e</literal>),
       whereas with the <literal>let</literal> form, the expression
@@ -448,22 +465,16 @@ Prelude> print x
 *** Exception: help!
 Prelude>
 </screen>
-<para>GHCi will print the result of a 
-<literal>x&lt;-e</literal> statement if and only if:
-<itemizedlist>
-<listitem><para>The statement binds exactly one variable</para></listitem>
-<listitem><para>The variable's type is not polymorphic, is not
-<literal>()</literal>,
-and is an instance of <literal>Show</literal>
-</para></listitem>
-</itemizedlist>
+
+      <para>Note that <literal>let</literal> bindings do not automatically
+       print the value bound, unlike monadic bindings.</para>
+
       <para>Any exceptions raised during the evaluation or execution
       of the statement are caught and printed by the GHCi command line
       interface (for more information on exceptions, see the module
       <literal>Control.Exception</literal> in the libraries
       documentation).</para>
 
-
       <para>Every new binding shadows any existing bindings of the
       same name, including entities that are in scope in the current
       module context.</para>
@@ -493,7 +504,7 @@ Prelude> let (x:xs) = [1..]
 x :: Integer
 xs :: [Integer]
 </screen>
-</para>
+
     </sect2>
 
     <sect2 id="ghci-scope">
@@ -698,7 +709,8 @@ Wed Mar 14 12:23:13 GMT 2001
    At the GHCi prompt, the second and third rules are relaxed as follows
    (differences italicised):
        <itemizedlist>
-           <listitem><para> <emphasis>Any</emphasis> of the classes <literal>Ci</literal> is standard.</para></listitem>
+           <listitem><para> <emphasis>All</emphasis> of the classes
+           <literal>Ci</literal> are single-parameter type classes.</para></listitem>
            <listitem><para> At least one of the classes <literal>Ci</literal> is
            numeric, <emphasis>or is <literal>Show</literal>, 
                <literal>Eq</literal>, or <literal>Ord</literal></emphasis>.</para></listitem>
@@ -1085,7 +1097,7 @@ Prelude> :. cmds.ghci
       <varlistentry>
        <term>
           <literal>:set</literal> <literal>args</literal> <replaceable>arg</replaceable> ...
-          <indexterm><primary><literal>:set</literal></primary></indexterm>
+          <indexterm><primary><literal>:set args</literal></primary></indexterm>
         </term>
        <listitem>
          <para>Sets the list of arguments which are returned when the
@@ -1097,7 +1109,7 @@ Prelude> :. cmds.ghci
       <varlistentry>
        <term>
            <literal>:set</literal> <literal>prog</literal> <replaceable>prog</replaceable>
-           <indexterm><primary><literal>:set</literal></primary></indexterm>
+           <indexterm><primary><literal>:set prog</literal></primary></indexterm>
         </term>
        <listitem>
          <para>Sets the string to be returned when the program calls
@@ -1108,6 +1120,19 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
+           <literal>:set</literal> <literal>prompt</literal> <replaceable>prompt</replaceable>
+        </term>
+       <listitem>
+         <para>Sets the string to be used as the prompt in GHCi.
+         Inside <replaceable>prompt</replaceable>, the sequence
+         <literal>%s</literal> is replaced by the names of the
+         modules currently in scope, and <literal>%%</literal> is
+         replaced by <literal>%</literal>.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:show bindings</literal>
           <indexterm><primary><literal>:show bindings</literal></primary></indexterm>
         </term>
@@ -1129,6 +1154,27 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
+         <literal>:ctags</literal> <optional><replaceable>filename</replaceable></optional>
+         <literal>:etags</literal> <optional><replaceable>filename</replaceable></optional>
+         <indexterm><primary><literal>:etags</literal></primary>
+         </indexterm>
+         <indexterm><primary><literal>:etags</literal></primary>
+         </indexterm>
+       </term>
+       <listitem>
+         <para>Generates a &ldquo;tags&rdquo; file for Vi-style editors
+           (<literal>:ctags</literal>) or Emacs-style editors (<literal>etags</literal>).  If
+           no filename is specified, the defaulit <filename>tags</filename> or
+           <filename>TAGS</filename> is
+           used, respectively.  Tags for all the functions, constructors and
+           types in the currently loaded modules are created.  All modules must
+           be interpreted for these commands to work.</para>
+          <para>See also <xref linkend="hasktags" />.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
          <literal>:type</literal> <replaceable>expression</replaceable>
          <indexterm><primary><literal>:type</literal></primary></indexterm>
         </term>