Fix alphabetical ordering in user guide
[ghc-hetmet.git] / docs / users_guide / ghci.xml
index f3a50dc..7fd49e7 100644 (file)
@@ -18,7 +18,7 @@
   <indexterm><primary>FFI</primary><secondary>GHCi support</secondary></indexterm>
   <indexterm><primary>Foreign Function
   Interface</primary><secondary>GHCi support</secondary></indexterm>.
   <indexterm><primary>FFI</primary><secondary>GHCi support</secondary></indexterm>
   <indexterm><primary>Foreign Function
   Interface</primary><secondary>GHCi support</secondary></indexterm>.
-  GHCi also includes an interactive debugger (see <xref linkend="ghci-debugger"/>)..</para>
+  GHCi also includes an interactive debugger (see <xref linkend="ghci-debugger"/>).</para>
 
   <sect1 id="ghci-introduction">
     <title>Introduction to GHCi</title>
 
   <sect1 id="ghci-introduction">
     <title>Introduction to GHCi</title>
 
 <screen>
 $ ghci
 
 <screen>
 $ ghci
-   ___         ___ _
-  / _ \ /\  /\/ __(_)
- / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
-/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
-\____/\/ /_/\____/|_|      Type :? for help.
-
+GHCi, version 6.8.1: http://www.haskell.org/ghc/  :? for help
 Loading package base ... linking ... done.
 Prelude> 
 </screen>
 
     <para>There may be a short pause while GHCi loads the prelude and
 Loading package base ... linking ... done.
 Prelude> 
 </screen>
 
     <para>There may be a short pause while GHCi loads the prelude and
-    standard libraries, after which the prompt is shown.  If we follow
-    the instructions and type <literal>:?</literal> for help, we
-    get:</para>
-
-<screen>
- Commands available from the prompt:
-
-   &lt;stmt&gt;                      evaluate/run &lt;stmt&gt;
-   :add &lt;filename&gt; ...         add module(s) to the current target set
-   :browse [*]&lt;module&gt;         display the names defined by &lt;module&gt;
-   :cd &lt;dir&gt;                   change directory to &lt;dir&gt;
-   :def &lt;cmd&gt; &lt;expr&gt;           define a command :&lt;cmd&gt;
-   :edit &lt;file&gt;                edit file
-   :edit                       edit last module
-   :help, :?                   display this list of commands
-   :info [&lt;name&gt; ...]          display information about the given names
-   :load &lt;filename&gt; ...        load module(s) and their dependents
-   :module [+/-] [*]&lt;mod&gt; ...  set the context for expression evaluation
-   :main [&lt;arguments&gt; ...]     run the main function with the given arguments
-   :reload                     reload the current module set
-
-   :set &lt;option&gt; ...           set options
-   :set args &lt;arg&gt; ...         set the arguments returned by System.getArgs
-   :set prog &lt;progname&gt;        set the value returned by System.getProgName
-   :set prompt &lt;prompt&gt;        set the prompt used in GHCi
-   :set editor &lt;cmd&gt;        set the command used for :edit
-
-   :show modules               show the currently loaded modules
-   :show bindings              show the current bindings made at the prompt
-
-   :ctags [&lt;file&gt;]             create tags file for Vi (default: "tags")
-   :etags [&lt;file&gt;]             create tags file for Emacs (default: "TAGS")
-   :type &lt;expr&gt;                show the type of &lt;expr&gt;
-   :kind &lt;type&gt;                show the kind of &lt;type&gt;
-   :undef &lt;cmd&gt;                undefine user-defined command :&lt;cmd&gt;
-   :unset &lt;option&gt; ...         unset options
-   :quit                       exit GHCi
-   :!&lt;command&gt;                 run the shell command &lt;command&gt;
-
- Options for ':set' and ':unset':
-
-    +r            revert top-level expressions after each evaluation
-    +s            print timing/memory stats after each evaluation
-    +t            print type after evaluation
-    -&lt;flags&gt;      most GHC command line flags can also be set here
-                         (eg. -v2, -fglasgow-exts, etc.)
-</screen>
+    standard libraries, after which the prompt is shown. As the banner
+    says, you can type <literal>:?</literal> to see the list of commands
+    available, and a half line description of each of them.</para>
 
     <para>We'll explain most of these commands as we go along.  For
     Hugs users: many things work the same as in Hugs, so you should be
 
     <para>We'll explain most of these commands as we go along.  For
     Hugs users: many things work the same as in Hugs, so you should be
@@ -268,19 +219,17 @@ Ok, modules loaded: Main.
 <screen>
 Prelude> :! ghc -c D.hs
 Prelude> :load A
 <screen>
 Prelude> :! ghc -c D.hs
 Prelude> :load A
-Skipping  D                ( D.hs, D.o )
-Compiling C                ( C.hs, interpreted )
 Compiling B                ( B.hs, interpreted )
 Compiling B                ( B.hs, interpreted )
+Compiling C                ( C.hs, interpreted )
 Compiling A                ( A.hs, interpreted )
 Ok, modules loaded: A, B, C, D.
 *Main>
 </screen>
 
 Compiling A                ( A.hs, interpreted )
 Ok, modules loaded: A, B, C, D.
 *Main>
 </screen>
 
-    <para>In the messages from the compiler, we see that it skipped D,
-    and used the object file <filename>D.o</filename>.  The message
-    <literal>Skipping</literal> <replaceable>module</replaceable>
-    indicates that compilation for <replaceable>module</replaceable>
-    isn't necessary, because the source and everything it depends on
+    <para>In the messages from the compiler, we see that there is no line
+    for <literal>D</literal>. This is because
+    it isn't necessary to compile <literal>D</literal>,
+    because the source and everything it depends on
     is unchanged since the last compilation.</para>
 
     <para>At any time you can use the command 
     is unchanged since the last compilation.</para>
 
     <para>At any time you can use the command 
@@ -296,7 +245,7 @@ B                ( B.hs, interpreted )
 A                ( A.hs, interpreted )
 *Main></screen>
 
 A                ( A.hs, interpreted )
 *Main></screen>
 
-    <para>If we now modify the source of D (or pretend to: using Unix
+    <para>If we now modify the source of D (or pretend to: using the Unix
     command <literal>touch</literal> on the source file is handy for
     this), the compiler will no longer be able to use the object file,
     because it might be out of date:</para>
     command <literal>touch</literal> on the source file is handy for
     this), the compiler will no longer be able to use the object file,
     because it might be out of date:</para>
@@ -305,9 +254,6 @@ A                ( A.hs, interpreted )
 *Main> :! touch D.hs
 *Main> :reload
 Compiling D                ( D.hs, interpreted )
 *Main> :! touch D.hs
 *Main> :reload
 Compiling D                ( D.hs, interpreted )
-Skipping  C                ( C.hs, interpreted )
-Skipping  B                ( B.hs, interpreted )
-Skipping  A                ( A.hs, interpreted )
 Ok, modules loaded: A, B, C, D.
 *Main> 
 </screen>
 Ok, modules loaded: A, B, C, D.
 *Main> 
 </screen>
@@ -323,8 +269,8 @@ Ok, modules loaded: A, B, C, D.
 *Main> :! ghc -c C.hs
 *Main> :load A
 Compiling D                ( D.hs, interpreted )
 *Main> :! ghc -c C.hs
 *Main> :load A
 Compiling D                ( D.hs, interpreted )
-Compiling C                ( C.hs, interpreted )
 Compiling B                ( B.hs, interpreted )
 Compiling B                ( B.hs, interpreted )
+Compiling C                ( C.hs, interpreted )
 Compiling A                ( A.hs, interpreted )
 Ok, modules loaded: A, B, C, D.
 </screen>
 Compiling A                ( A.hs, interpreted )
 Ok, modules loaded: A, B, C, D.
 </screen>
@@ -347,8 +293,6 @@ Ok, modules loaded: A, B, C, D.
 
 <screen>
 *Main> :load A
 
 <screen>
 *Main> :load A
-Skipping  D                ( D.hs, D.o )
-Skipping  C                ( C.hs, C.o )
 Compiling B                ( B.hs, interpreted )
 Compiling A                ( A.hs, interpreted )
 Ok, modules loaded: A, B, C, D.
 Compiling B                ( B.hs, interpreted )
 Compiling A                ( A.hs, interpreted )
 Ok, modules loaded: A, B, C, D.
@@ -359,7 +303,7 @@ Ok, modules loaded: A, B, C, D.
     when working on a large program is to occasionally run
     <literal>ghc &ndash;&ndash;make</literal> to compile the whole project (say
     before you go for lunch :-), then continue working in the
     when working on a large program is to occasionally run
     <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
+    interpreter.  As you modify code, the changed modules will be
     interpreted, but the rest of the project will remain
     compiled.</para>
 
     interpreted, but the rest of the project will remain
     compiled.</para>
 
@@ -577,7 +521,9 @@ hello
 Prelude IO>
 </screen>
 
 Prelude IO>
 </screen>
 
-      <para>(Note: <literal>:module</literal> can be shortened to
+      <para>(Note: you can use <literal>import M</literal> as an
+      alternative to <literal>:module +M</literal>, and
+      <literal>:module</literal> can also be shortened to 
       <literal>:m</literal>). The full syntax of the
       <literal>:module</literal> command is:</para>
 
       <literal>:m</literal>). The full syntax of the
       <literal>:module</literal> command is:</para>
 
@@ -618,7 +564,7 @@ Prelude IO>
       <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>
       <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>.
+        then GHCi will expand it to &ldquo;<literal>Just </literal>&rdquo;.
       </para>
 
       <sect3>
       </para>
 
       <sect3>
@@ -769,7 +715,7 @@ it &lt;- <replaceable>e</replaceable>
         </listitem>
     </orderedlist>
     At the GHCi prompt, or with GHC if the
         </listitem>
     </orderedlist>
     At the GHCi prompt, or with GHC if the
-    <literal>-fextended-default-rules</literal> flag is given,
+    <literal>-XExtendedDefaultRules</literal> flag is given,
     the following additional differences apply:
     <itemizedlist>
         <listitem>
     the following additional differences apply:
     <itemizedlist>
         <listitem>
@@ -818,8 +764,8 @@ def = toEnum 0
     instance that returns <literal>IO a</literal>.
     However, it is only able to return
     <literal>undefined</literal>
     instance that returns <literal>IO a</literal>.
     However, it is only able to return
     <literal>undefined</literal>
-    (the reason for the instance having this type is to not require
-    extensions to the class system), so if the type defaults to
+    (the reason for the instance having this type is so that printf
+    doesn't require extensions to the class system), so if the type defaults to
     <literal>Integer</literal> then ghci gives an error when running a
     printf.
    </para>
     <literal>Integer</literal> then ghci gives an error when running a
     printf.
    </para>
@@ -842,7 +788,7 @@ def = toEnum 0
     <para>The debugger provides the following:
     <itemizedlist>
         <listitem>
     <para>The debugger provides the following:
     <itemizedlist>
         <listitem>
-          <para>The abilty to set a <firstterm>breakpoint</firstterm> on a
+          <para>The ability to set a <firstterm>breakpoint</firstterm> on a
             function definition or expression in the program.  When the function
             is called, or the expression evaluated, GHCi suspends 
             execution and returns to the prompt, where you can inspect the
             function definition or expression in the program.  When the function
             is called, or the expression evaluated, GHCi suspends 
             execution and returns to the prompt, where you can inspect the
@@ -1071,7 +1017,7 @@ right :: [a]
       <para>The execution continued at the point it previously stopped, and has
         now stopped at the breakpoint for a second time.</para>
 
       <para>The execution continued at the point it previously stopped, and has
         now stopped at the breakpoint for a second time.</para>
 
-      <sect3 id="setting-breakpoings">
+      <sect3 id="setting-breakpoints">
         <title>Setting breakpoints</title>
 
         <para>Breakpoints can be set in various ways.  Perhaps the easiest way to
         <title>Setting breakpoints</title>
 
         <para>Breakpoints can be set in various ways.  Perhaps the easiest way to
@@ -1134,7 +1080,7 @@ right :: [a]
         <title>Listing and deleting breakpoints</title>
 
         <para>The list of breakpoints currently enabled can be displayed using
         <title>Listing and deleting breakpoints</title>
 
         <para>The list of breakpoints currently enabled can be displayed using
-          <literal>:show&nbsp;breaks</literal></para>:
+          <literal>:show&nbsp;breaks</literal>:</para>
 <screen>
 *Main> :show breaks
 [0] Main qsort.hs:1:11-12
 <screen>
 *Main> :show breaks
 [0] Main qsort.hs:1:11-12
@@ -1373,7 +1319,9 @@ a :: a
         have no context information attached to them.  Finding which
         particular call to <literal>head</literal> in your program resulted in
         the error can be a painstaking process, usually involving
         have no context information attached to them.  Finding which
         particular call to <literal>head</literal> in your program resulted in
         the error can be a painstaking process, usually involving
-        <literal>Debug.Trace.trace</literal>.</para>
+        <literal>Debug.Trace.trace</literal>, or compiling with
+        profiling and using <literal>+RTS -xc</literal> (see <xref
+          linkend="prof-time-options" />).</para>
 
       <para>The GHCi debugger offers a way to hopefully shed some light on
         these errors quickly and without modifying or recompiling the source
 
       <para>The GHCi debugger offers a way to hopefully shed some light on
         these errors quickly and without modifying or recompiling the source
@@ -1540,7 +1488,7 @@ Just 20
         </listitem>
        <listitem><para>
          Implicit parameters (see <xref linkend="implicit-parameters"/>) are only available 
         </listitem>
        <listitem><para>
          Implicit parameters (see <xref linkend="implicit-parameters"/>) are only available 
-         at the scope of a breakpoint if there is a explicit type signature.
+         at the scope of a breakpoint if there is an explicit type signature.
        </para>
         </listitem>
       </itemizedlist>
        </para>
         </listitem>
       </itemizedlist>
@@ -1568,9 +1516,7 @@ $ ghci Main.hs
 
     <para>Most of the command-line options accepted by GHC (see <xref
     linkend="using-ghc"/>) also make sense in interactive mode.  The ones
 
     <para>Most of the command-line options accepted by GHC (see <xref
     linkend="using-ghc"/>) also make sense in interactive mode.  The ones
-    that don't make sense are mostly obvious; for example, GHCi
-    doesn't generate interface files, so options related to interface
-    file generation won't have any effect.</para>
+    that don't make sense are mostly obvious.</para>
 
     <sect2>
       <title>Packages</title>
 
     <sect2>
       <title>Packages</title>
@@ -1586,12 +1532,7 @@ $ ghci Main.hs
 
 <screen>
 $ ghci -package readline
 
 <screen>
 $ ghci -package readline
-   ___         ___ _
-  / _ \ /\  /\/ __(_)
- / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
-/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
-\____/\/ /_/\____/|_|      Type :? for help.
-
+GHCi, version 6.8.1: http://www.haskell.org/ghc/  :? for help
 Loading package base ... linking ... done.
 Loading package readline-1.0 ... linking ... done.
 Prelude> 
 Loading package base ... linking ... done.
 Loading package readline-1.0 ... linking ... done.
 Prelude> 
@@ -1672,6 +1613,17 @@ $ ghci -lm
     <variablelist>
       <varlistentry>
        <term>
     <variablelist>
       <varlistentry>
        <term>
+          <literal>:abandon</literal>
+          <indexterm><primary><literal>:abandon</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Abandons the current evaluation (only available when stopped at
+          a breakpoint).</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:add</literal> <replaceable>module</replaceable> ...
           <indexterm><primary><literal>:add</literal></primary></indexterm>
         </term>
           <literal>:add</literal> <replaceable>module</replaceable> ...
           <indexterm><primary><literal>:add</literal></primary></indexterm>
         </term>
@@ -1684,12 +1636,27 @@ $ ghci -lm
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
-          <literal>:breakpoint</literal> <replaceable>list|add|continue|del|stop|step</replaceable> ...
-          <indexterm><primary><literal>:breakpoint</literal></primary></indexterm>
+          <literal>:back</literal>
+          <indexterm><primary><literal>:back</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Travel back one step in the history.  See <xref
+              linkend="tracing" />.  See also:
+            <literal>:trace</literal>, <literal>:history</literal>,
+            <literal>:forward</literal>.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
+          <literal>:break [<replaceable>identifier</replaceable> |
+            [<replaceable>module</replaceable>] <replaceable>line</replaceable>
+            [<replaceable>column</replaceable>]]</literal>
         </term>
         </term>
+          <indexterm><primary><literal>:break</literal></primary></indexterm>
        <listitem>
        <listitem>
-         <para>Permits to add, delete or list the breakpoints in a debugging session.
-         </para>
+         <para>Set a breakpoint on the specified function or line and
+              column.  See <xref linkend="setting-breakpoints" />.</para>
        </listitem>
       </varlistentry>
 
        </listitem>
       </varlistentry>
 
@@ -1737,10 +1704,46 @@ $ ghci -lm
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+          <literal>:cmd</literal> <replaceable>expr</replaceable>
+          <indexterm><primary><literal>:cmd</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Executes <replaceable>expr</replaceable> as a computation of
+            type <literal>IO String</literal>, and then executes the resulting
+            string as a list of GHCi commands.  Multiple commands are separated
+            by newlines.  The <literal>:cmd</literal> command is useful with
+            <literal>:def</literal> and <literal>:set stop</literal>.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:continue</literal> 
           <indexterm><primary><literal>:continue</literal></primary></indexterm>
         </term>
           <literal>:continue</literal> 
           <indexterm><primary><literal>:continue</literal></primary></indexterm>
         </term>
-       <listitem><para>Shortcut to <literal>:breakpoint continue</literal></para>
+       <listitem><para>Continue the current evaluation, when stopped at a
+            breakpoint.</para>
+       </listitem>
+      </varlistentry>
+
+      <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>
 
        </listitem>
       </varlistentry>
 
@@ -1814,6 +1817,18 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+          <literal>:delete * | <replaceable>num</replaceable> ...</literal> 
+          <indexterm><primary><literal>:delete</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Delete one or more breakpoints by number (use <literal>:show
+              breaks</literal> to see the number of each breakpoint).  The
+            <literal>*</literal> form deletes all the breakpoints.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:edit <optional><replaceable>file</replaceable></optional></literal>
           <indexterm><primary><literal>:edit</literal></primary></indexterm>
         </term>
           <literal>:edit <optional><replaceable>file</replaceable></optional></literal>
           <indexterm><primary><literal>:edit</literal></primary></indexterm>
         </term>
@@ -1830,6 +1845,34 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+          <literal>:force <replaceable>identifier</replaceable> ...</literal>
+          <indexterm><primary><literal>:force</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Prints the value of <replaceable>identifier</replaceable> in
+            the same way as <literal>:print</literal>.   Unlike
+            <literal>:print</literal>, <literal>:force</literal> evaluates each
+            thunk that it encounters while traversing the value.  This may
+            cause exceptions or infinite loops, or further breakpoints (which
+            are ignored, but displayed).</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
+          <literal>:forward</literal>
+          <indexterm><primary><literal>:forward</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Move forward in the history.   See <xref
+              linkend="tracing" />.  See also:
+            <literal>:trace</literal>, <literal>:history</literal>,
+            <literal>:back</literal>.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:help</literal>
           <indexterm><primary><literal>:help</literal></primary></indexterm>
         </term>
           <literal>:help</literal>
           <indexterm><primary><literal>:help</literal></primary></indexterm>
         </term>
@@ -1844,6 +1887,19 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+          <literal>:history [<replaceable>num</replaceable>]</literal>
+          <indexterm><primary><literal>:history</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Display the history of evaluation steps.  With a number,
+            displays that many steps (default: 20).  For use with
+            <literal>:trace</literal>; see <xref
+              linkend="tracing" />.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:info</literal> <replaceable>name</replaceable> ...
           <indexterm><primary><literal>:info</literal></primary></indexterm>
         </term>
           <literal>:info</literal> <replaceable>name</replaceable> ...
           <indexterm><primary><literal>:info</literal></primary></indexterm>
         </term>
@@ -1862,6 +1918,19 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+          <literal>:kind</literal> <replaceable>type</replaceable>
+          <indexterm><primary><literal>:kind</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Infers and prints the kind of
+         <replaceable>type</replaceable>. The latter can be an arbitrary
+           type expression, including a partial application of a type constructor,
+           such as <literal>Either Int</literal>.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:load</literal> <replaceable>module</replaceable> ...
           <indexterm><primary><literal>:load</literal></primary></indexterm>
         </term>
           <literal>:load</literal> <replaceable>module</replaceable> ...
           <indexterm><primary><literal>:load</literal></primary></indexterm>
         </term>
@@ -1936,9 +2005,15 @@ Prelude> :main foo bar
           <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>
           <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>
+        <term>
+          <literal>import <replaceable>mod</replaceable></literal>
+        </term>
        <listitem>
          <para>Sets or modifies the current context for statements
        <listitem>
          <para>Sets or modifies the current context for statements
-         typed at the prompt.  See <xref linkend="ghci-scope"/> for
+         typed at the prompt.  The form <literal>import
+         <replaceable>mod</replaceable></literal> is equivalent to
+         <literal>:module +<replaceable>mod</replaceable></literal>.
+         See <xref linkend="ghci-scope"/> for
          more details.</para>
        </listitem>
       </varlistentry>
          more details.</para>
        </listitem>
       </varlistentry>
@@ -1949,39 +2024,19 @@ Prelude> :main foo bar
           <indexterm><primary><literal>:print</literal></primary></indexterm>
         </term>
        <listitem>
           <indexterm><primary><literal>:print</literal></primary></indexterm>
         </term>
        <listitem>
-         <para> Prints a semievaluated value without forcing its evaluation. 
-         <literal>:print </literal> works just like <literal>:sprint</literal> but additionally, 
-           <literal>:print</literal> binds the unevaluated parts -called 
-          <quote>suspensions</quote>-
-         to names which you can play with. For example:
-<screen>
-Prelude> let li = map Just [1..5]
-Prelude> :sp li
-li - _
-Prelude> :p li
-li - (_t1::[Maybe Integer])
-Prelude> head li
-Just 1
-Prelude> :sp li
-li - Just 1 : _
-Prelude> :p li
-li - Just 1 : (_t2::[Maybe Integer])
-Prelude> last li
-Just 5
-Prelude> :sp li
-li - [Just 1,_,_,_,Just 5]
-Prelude> :p li
-li - [Just 1,(_t3::Maybe Integer),(_t4::Maybe Integer),(_t5::Maybe Integer),Just 4]
-Prelude> _t4
-Just 3
-Prelude> :p li
-li - [Just 1,(_t6::Maybe Integer),Just 3,(_t7::Maybe Integer),Just 4]
-</screen>
-         The example uses <literal>:print</literal> and  <literal>:sprint</literal> 
-        to help us observe how the <literal>li</literal> variable is evaluated progressively as we operate
-         with it. Note for instance how <quote>last</quote> traverses all the elements of
-        the list to compute its result, but without evaluating the individual elements.
-         </para>
+         <para>Prints a value without forcing its evaluation.
+            <literal>:print</literal> may be used on values whose types are
+            unkonwn or partially known, which might be the case for local
+            variables with polymorphic types at a breakpoint.  While inspecting
+            the runtime value, <literal>:print</literal> attempts to
+            reconstruct the type of the value, and will elaborate the type in
+            GHCi's environment if possible.  If any unevaluated components
+            (thunks) are encountered, then <literal>:print</literal> binds
+            a fresh variable with a name beginning with <literal>_t</literal>
+            to each thunk.  See <xref linkend="breakpoints" /> for more
+            information.  See also the <literal>:sprint</literal> command,
+            which works like <literal>:print</literal> but does not bind new
+            variables.</para>
        </listitem>
       </varlistentry>
 
        </listitem>
       </varlistentry>
 
@@ -2072,6 +2127,35 @@ li - [Just 1,(_t6::Maybe Integer),Just 3,(_t7::Maybe Integer),Just 4]
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+           <literal>:set</literal> <literal>stop</literal>
+          [<replaceable>num</replaceable>] <replaceable>cmd</replaceable>
+        </term>
+       <listitem>
+         <para>Set a command to be executed when a breakpoint is hit, or a new
+          item in the history is selected.  The most common use of
+            <literal>:set stop</literal> is to display the source code at the
+            current location, e.g. <literal>:set stop :list</literal>.</para>
+
+          <para>If a number is given before the command, then the commands are
+            run when the specified breakpoint (only) is hit.  This can be quite
+            useful: for example, <literal>:set stop 1 :continue</literal>
+            effectively disables breakpoint 1, by running
+            <literal>:continue</literal> whenever it is hit (although GHCi will
+            still emit a message to say the breakpoint was hit).  What's more,
+            with cunning use of <literal>:def</literal> and
+            <literal>:cmd</literal> you can use <literal>:set stop</literal> to
+            implement conditional breakpoints:</para>
+<screen>
+*Main> :def cond \expr -> return (":cmd if (" ++ expr ++ ") then return \"\" else return \":continue\"")
+*Main> :set stop 0 :cond (x &lt; 3)
+</screen>
+          <para>Ignoring breakpoints for a specified number of iterations is
+            also possible using similar techniques.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:show bindings</literal>
           <indexterm><primary><literal>:show bindings</literal></primary></indexterm>
         </term>
           <literal>:show bindings</literal>
           <indexterm><primary><literal>:show bindings</literal></primary></indexterm>
         </term>
@@ -2083,6 +2167,26 @@ li - [Just 1,(_t6::Maybe Integer),Just 3,(_t7::Maybe Integer),Just 4]
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+          <literal>:show breaks</literal>
+          <indexterm><primary><literal>:show breaks</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>List the active breakpoints.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
+          <literal>:show context</literal>
+          <indexterm><primary><literal>:show context</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>List the active evaluations that are stopped at breakpoints.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:show modules</literal>
           <indexterm><primary><literal>:show modules</literal></primary></indexterm>
         </term>
           <literal>:show modules</literal>
           <indexterm><primary><literal>:show modules</literal></primary></indexterm>
         </term>
@@ -2090,79 +2194,67 @@ li - [Just 1,(_t6::Maybe Integer),Just 3,(_t7::Maybe Integer),Just 4]
          <para>Show the list of modules currently load.</para>
        </listitem>
       </varlistentry>
          <para>Show the list of modules currently load.</para>
        </listitem>
       </varlistentry>
+
+      <varlistentry>
+       <term>
+          <literal>:show [args|prog|prompt|editor|stop]</literal>
+          <indexterm><primary><literal>:show</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Displays the specified setting (see
+            <literal>:set</literal>).</para>
+       </listitem>
+      </varlistentry>
+
       <varlistentry>
        <term>
           <literal>:sprint</literal>
           <indexterm><primary><literal>:sprint</literal></primary></indexterm>
         </term>
        <listitem>
       <varlistentry>
        <term>
           <literal>:sprint</literal>
           <indexterm><primary><literal>:sprint</literal></primary></indexterm>
         </term>
        <listitem>
-         <para>Prints a semievaluated value without forcing its evaluation. 
-         <literal>:sprint</literal> and its sibling <literal>:print</literal> 
-         are very useful to observe how lazy evaluation works in your code. For example:
-<screen>
-Prelude> let li = map Just [1..5]
-Prelude> :sp li
-li - _
-Prelude> head li
-Just 1
-Prelude> :sp li
-li - Just 1 : _
-Prelude> last li
-Just 5
-Prelude> :sp li
-li - [Just 1,_,_,_,Just 5]
-</screen>
-         The example uses <literal>:sprint</literal> to help us observe how the <literal>li</literal> variable is evaluated progressively as we operate
-         with it. Note for instance how <quote>last</quote> traverses all the elements of
-        the list to compute its result, but without evaluating the individual elements.
-         </para>
+         <para>Prints a value without forcing its evaluation.
+            <literal>:sprint</literal> is similar to <literal>:print</literal>,
+            with the difference that unevaluated subterms are not bound to new
+            variables, they are simply denoted by &lsquo;_&rsquo;.</para>
        </listitem>
       </varlistentry>
        </listitem>
       </varlistentry>
+
       <varlistentry>
        <term>
       <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>
+          <literal>:step [<replaceable>expr</replaceable>]</literal> 
+          <indexterm><primary><literal>:step</literal></primary></indexterm>
+        </term>
        <listitem>
        <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>
+         <para>Single-step from the last breakpoint.  With an expression
+            argument, begins evaluation of the expression with a
+            single-step.</para>
        </listitem>
       </varlistentry>
 
       <varlistentry>
        <term>
        </listitem>
       </varlistentry>
 
       <varlistentry>
        <term>
-         <literal>:type</literal> <replaceable>expression</replaceable>
-         <indexterm><primary><literal>:type</literal></primary></indexterm>
+          <literal>:trace [<replaceable>expr</replaceable>]</literal>
+          <indexterm><primary><literal>:trace</literal></primary></indexterm>
         </term>
        <listitem>
         </term>
        <listitem>
-         <para>Infers and prints the type of
-         <replaceable>expression</replaceable>, including explicit
-         forall quantifiers for polymorphic types.  The monomorphism
-         restriction is <emphasis>not</emphasis> applied to the
-         expression during type inference.</para>
+         <para>Evaluates the given expression (or from the last breakpoint if
+            no expression is given), and additionally logs the evaluation
+            steps for later inspection using <literal>:history</literal>.  See
+            <xref linkend="tracing" />.</para>
        </listitem>
       </varlistentry>
 
       <varlistentry>
        <term>
        </listitem>
       </varlistentry>
 
       <varlistentry>
        <term>
-          <literal>:kind</literal> <replaceable>type</replaceable>
-          <indexterm><primary><literal>:kind</literal></primary></indexterm>
+         <literal>:type</literal> <replaceable>expression</replaceable>
+         <indexterm><primary><literal>:type</literal></primary></indexterm>
         </term>
        <listitem>
         </term>
        <listitem>
-         <para>Infers and prints the kind of
-         <replaceable>type</replaceable>. The latter can be an arbitrary
-           type expression, including a partial application of a type constructor,
-           such as <literal>Either Int</literal>.</para>
+         <para>Infers and prints the type of
+         <replaceable>expression</replaceable>, including explicit
+         forall quantifiers for polymorphic types.  The monomorphism
+         restriction is <emphasis>not</emphasis> applied to the
+         expression during type inference.</para>
        </listitem>
       </varlistentry>
 
        </listitem>
       </varlistentry>