:set prompt now understand Haskell String syntax; trace #2652
[ghc-hetmet.git] / docs / users_guide / ghci.xml
index d8d0a89..d929548 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
@@ -251,12 +202,12 @@ Ok, modules loaded: Main.
     very often, and use the interpreter for the code being actively
     developed.</para>
 
     very often, and use the interpreter for the code being actively
     developed.</para>
 
-    <para>When loading up source files with <literal>:load</literal>,
-    GHCi looks for any corresponding compiled object files, and will
-    use one in preference to interpreting the source if possible.  For
-    example, suppose we have a 4-module program consisting of modules
-    A, B, C, and D.  Modules B and C both import D only,
-    and A imports both B &amp; C:</para>
+    <para>When loading up source modules with <literal>:load</literal>,
+    GHCi normally looks for any corresponding compiled object files,
+    and will use one in preference to interpreting the source if
+    possible.  For example, suppose we have a 4-module program
+    consisting of modules A, B, C, and D.  Modules B and C both import
+    D only, and A imports both B &amp; C:</para>
 <screen>
       A
      / \
 <screen>
       A
      / \
@@ -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,22 +293,47 @@ 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.
 </screen>
 
 Compiling B                ( B.hs, interpreted )
 Compiling A                ( A.hs, interpreted )
 Ok, modules loaded: A, B, C, D.
 </screen>
 
+    <para>The automatic loading of object files can sometimes lead to
+    confusion, because non-exported top-level definitions of a module
+    are only available for use in expressions at the prompt when the
+    module is interpreted (see <xref linkend="ghci-scope" />).  For
+    this reason, you might sometimes want to force GHCi to load a
+    module using the interpreter.  This can be done by prefixing
+      a <literal>*</literal> to the module name or filename when
+      using <literal>:load</literal>, for example</para>
+
+<screen>
+Prelude> :load *A
+Compiling A                ( A.hs, interpreted )
+*A>
+</screen>
+
+<para>When the <literal>*</literal> is used, GHCi ignores any
+  pre-compiled object code and interprets the module.  If you have
+  already loaded a number of modules as object code and decide that
+  you wanted to interpret one of them, instead of re-loading the whole
+  set you can use <literal>:add *M</literal> to specify that you want
+  <literal>M</literal> to be interpreted (note that this might cause
+  other modules to be interpreted too, because compiled modules cannot
+  depend on interpreted ones).</para>
+
+<para>To always compile everything to object code and never use the
+  interpreter, use the <literal>-fobject-code</literal> option (see
+  <xref linkend="ghci-obj" />).</para>
+
     <para>HINT: since GHCi will only use a compiled object file if it
     can be sure that the compiled version is up-to-date, a good technique
     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
     <para>HINT: since GHCi will only use a compiled object file if it
     can be sure that the compiled version is up-to-date, a good technique
     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>
-
   </sect1>
 
   <sect1 id="interactive-evaluation">
   </sect1>
 
   <sect1 id="interactive-evaluation">
@@ -424,7 +395,6 @@ hello
       <literal>IO</literal> monad.
 <screen>
 Prelude> x &lt;- return 42
       <literal>IO</literal> monad.
 <screen>
 Prelude> x &lt;- return 42
-42
 Prelude> print x
 42
 Prelude>
 Prelude> print x
 42
 Prelude>
@@ -436,7 +406,8 @@ Prelude>
       <literal>x</literal> in future statements, for example to print
       it as we did above.</para>
 
       <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: 
+      <para>If <option>-fprint-bind-result</option> is set then
+      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 
        <itemizedlist>
          <listitem>
            <para>The statement is not a binding, or it is a monadic binding 
@@ -449,13 +420,8 @@ Prelude>
              <literal>Show</literal></para>
          </listitem>
        </itemizedlist>
              <literal>Show</literal></para>
          </listitem>
        </itemizedlist>
-      The automatic printing of binding results can be supressed with
-      <option>:set -fno-print-bind-result</option> (this does not
-      supress printing the result of non-binding statements).
-      <indexterm><primary><option>-fno-print-bind-result</option></primary></indexterm><indexterm><primary><option>-fprint-bind-result</option></primary></indexterm>.
-      You might want to do this to prevent the result of binding
-      statements from being fully evaluated by the act of printing
-      them, for example.</para>
+      <indexterm><primary><option>-fprint-bind-result</option></primary></indexterm><indexterm><primary><option>-fno-print-bind-result</option></primary></indexterm>.
+      </para>
 
       <para>Of course, you can also bind normal non-IO expressions
       using the <literal>let</literal>-statement:</para>
 
       <para>Of course, you can also bind normal non-IO expressions
       using the <literal>let</literal>-statement:</para>
@@ -480,6 +446,45 @@ Prelude>
       <para>Note that <literal>let</literal> bindings do not automatically
        print the value bound, unlike monadic bindings.</para>
 
       <para>Note that <literal>let</literal> bindings do not automatically
        print the value bound, unlike monadic bindings.</para>
 
+      <para>Hint: you can also use <literal>let</literal>-statements
+      to define functions at the prompt:</para>
+<screen>
+Prelude> let add a b = a + b
+Prelude> add 1 2
+3
+Prelude>
+</screen>
+        <para>However, this quickly gets tedious when defining functions 
+        with multiple clauses, or groups of mutually recursive functions,
+        because the complete definition has to be given on a single line, 
+        using explicit braces and semicolons instead of layout:</para>
+<screen>
+Prelude> let { f op n [] = n ; f op n (h:t) = h `op` f op n t }
+Prelude> f (+) 0 [1..3]
+6
+Prelude>
+</screen>
+      <para>To alleviate this issue, GHCi commands can be split over
+      multiple lines, by wrapping them in <literal>:{</literal> and
+      <literal>:}</literal> (each on a single line of its own):</para>
+<screen>
+Prelude> :{
+Prelude| let { g op n [] = n
+Prelude|     ; g op n (h:t) = h `op` g op n t
+Prelude|     }
+Prelude| :}
+Prelude> g (*) 1 [1..3]
+6
+</screen>
+      <para>Such multiline commands can be used with any GHCi command,
+      and the lines between <literal>:{</literal> and
+      <literal>:}</literal> are simply merged into a single line for 
+      interpretation. That implies that each such group must form a single
+      valid command when merged, and that no layout rule is used. 
+      The main purpose of multiline commands is not to replace module
+      loading but to make definitions in .ghci-files (see <xref
+      linkend="ghci-dot-files"/>) more readable and maintainable.</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
       <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
@@ -559,10 +564,14 @@ Compiling Main             ( Main.hs, interpreted )
       scopes from multiple modules, in any mixture of
       <literal>*</literal> and non-<literal>*</literal> forms.  GHCi
       combines the scopes from all of these modules to form the scope
       scopes from multiple modules, in any mixture of
       <literal>*</literal> and non-<literal>*</literal> forms.  GHCi
       combines the scopes from all of these modules to form the scope
-      that is in effect at the prompt.  For technical reasons, GHCi
-      can only support the <literal>*</literal>-form for modules which
-      are interpreted, so compiled modules and package modules can
-      only contribute their exports to the current scope.</para>
+      that is in effect at the prompt.</para>
+
+      <para>NOTE: for technical reasons, GHCi can only support the
+      <literal>*</literal>-form for modules that are interpreted.
+      Compiled modules and package modules can only contribute their
+      exports to the current scope.  To ensure that GHCi loads the
+      interpreted version of a module, add the <literal>*</literal>
+      when loading the module, e.g. <literal>:load *M</literal>.</para>
 
       <para>The scope is manipulated using the
       <literal>:module</literal> command.  For example, if the current
 
       <para>The scope is manipulated using the
       <literal>:module</literal> command.  For example, if the current
@@ -577,7 +586,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,20 +629,56 @@ 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>
+        <title><literal>:module</literal> and
+        <literal>:load</literal></title>
+
+        <para>It might seem that <literal>:module</literal> and
+        <literal>:load</literal> do similar things: you can use both
+        to bring a module into scope.  However, there is a clear
+        difference.  GHCi is concerned with two sets of modules:</para>
+
+        <itemizedlist>
+          <listitem>
+            <para>The set of modules that are
+              currently <emphasis>loaded</emphasis>.  This set is
+              modified
+              by <literal>:load</literal>, <literal>:add</literal>
+              and <literal>:reload</literal>.
+            </para>
+          </listitem>
+          <listitem>
+            <para>The set of modules that are currently <emphasis>in
+                scope</emphasis> at the prompt.  This set is modified
+              by <literal>:module</literal>, and it is also set
+              automatically
+                after <literal>:load</literal>, <literal>:add</literal>,
+              and <literal>:reload</literal>.</para>
+          </listitem>
+        </itemizedlist>
+
+        <para>You cannot add a module to the scope if it is not
+          loaded.  This is why trying to
+          use <literal>:module</literal> to load a new module results
+          in the message &ldquo;<literal>module M is not
+            loaded</literal>&rdquo;.</para>
+      </sect3>
+
+      <sect3 id="ghci-import-qualified">
        <title>Qualified names</title>
 
        <para>To make life slightly easier, the GHCi prompt also
         behaves as if there is an implicit <literal>import
         qualified</literal> declaration for every module in every
        <title>Qualified names</title>
 
        <para>To make life slightly easier, the GHCi prompt also
         behaves as if there is an implicit <literal>import
         qualified</literal> declaration for every module in every
-        package, and every module currently loaded into GHCi.</para>
+        package, and every module currently loaded into GHCi.  This
+          behaviour can be disabled with the flag <option>-fno-implicit-import-qualified</option><indexterm><primary><option>-fno-implicit-import-qualified</option></primary></indexterm>.</para>
       </sect3>
 
       <sect3>
       </sect3>
 
       <sect3>
-        <title>The <literal>:main</literal> command</title>
+        <title>The <literal>:main</literal> and <literal>:run</literal> commands</title>
 
         <para>
           When a program is compiled and executed, it can use the
 
         <para>
           When a program is compiled and executed, it can use the
@@ -656,6 +703,37 @@ Prelude> :main foo bar
 ["foo","bar"]
 </screen>
 
 ["foo","bar"]
 </screen>
 
+        <para>
+            We can also quote arguments which contains characters like
+            spaces, and they are treated like Haskell strings, or we can
+            just use Haskell list syntax:
+        </para>
+
+<screen>
+Prelude> :main foo "bar baz"
+["foo","bar baz"]
+Prelude> :main ["foo", "bar baz"]
+["foo","bar baz"]
+</screen>
+
+        <para>
+            Finally, other functions can be called, either with the
+            <literal>-main-is</literal> flag or the <literal>:run</literal>
+            command:
+        </para>
+
+<screen>
+Prelude> let foo = putStrLn "foo" >> System.Environment.getArgs >>= print
+Prelude> let bar = putStrLn "bar" >> System.Environment.getArgs >>= print
+Prelude> :set -main-is foo
+Prelude> :main foo "bar baz"
+foo
+["foo","bar baz"]
+Prelude> :run bar ["foo", "bar baz"]
+bar
+["foo","bar baz"]
+</screen>
+
       </sect3>
     </sect2>
   
       </sect3>
     </sect2>
   
@@ -769,7 +847,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 +896,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>
@@ -834,15 +912,17 @@ def = toEnum 0
     <para>GHCi contains a simple imperative-style debugger in which you can
       stop a running computation in order to examine the values of
       variables.  The debugger is integrated into GHCi, and is turned on by
     <para>GHCi contains a simple imperative-style debugger in which you can
       stop a running computation in order to examine the values of
       variables.  The debugger is integrated into GHCi, and is turned on by
-      default: no flags are required to enable the debugging facilities.  There
-      is one major restriction: breakpoints and single-stepping are only
-      available in <emphasis>interpreted</emphasis> modules; compiled code is
-      invisible to the debugger.</para>
+      default: no flags are required to enable the debugging
+      facilities.  There is one major restriction: breakpoints and
+      single-stepping are only available in interpreted modules;
+      compiled code is invisible to the debugger<footnote><para>Note that packages
+      only contain compiled code, so debugging a package requires
+      finding its source and loading that directly.</para></footnote>.</para>
 
     <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
@@ -872,9 +952,12 @@ def = toEnum 0
     </para>
       
     <para>There is currently no support for obtaining a &ldquo;stack
     </para>
       
     <para>There is currently no support for obtaining a &ldquo;stack
-      trace&rdquo;, but the tracing and history features provide a useful
-      second-best, which will often be enough to establish the context of an
-      error.</para>
+    trace&rdquo;, but the tracing and history features provide a
+    useful second-best, which will often be enough to establish the
+    context of an error.  For instance, it is possible to break
+    automatically when an exception is thrown, even if it is thrown
+    from within compiled code (see <xref
+    linkend="ghci-debugger-exceptions" />).</para>
       
     <sect2 id="breakpoints">
       <title>Breakpoints and inspecting variables</title>
       
     <sect2 id="breakpoints">
       <title>Breakpoints and inspecting variables</title>
@@ -983,6 +1066,7 @@ right :: [a]
         <literal>left</literal>:</para>
 
 <screen>
         <literal>left</literal>:</para>
 
 <screen>
+[qsort.hs:2:15-46] *Main> :set -fprint-evld-with-show
 [qsort.hs:2:15-46] *Main> :print left
 left = (_t1::[a])
 </screen>
 [qsort.hs:2:15-46] *Main> :print left
 left = (_t1::[a])
 </screen>
@@ -1002,6 +1086,13 @@ left = (_t1::[a])
         underscore, in this case
         <literal>_t1</literal>.</para>
 
         underscore, in this case
         <literal>_t1</literal>.</para>
 
+      <para>The flag <literal>-fprint-evld-with-show</literal> instructs
+      <literal>:print</literal> to reuse
+      available <literal>Show</literal> instances when possible. This happens
+      only when the contents of the variable being inspected 
+      are completely evaluated.</para>
+
+
       <para>If we aren't concerned about preserving the evaluatedness of a
         variable, we can use <literal>:force</literal> instead of
         <literal>:print</literal>.  The <literal>:force</literal> command
       <para>If we aren't concerned about preserving the evaluatedness of a
         variable, we can use <literal>:force</literal> instead of
         <literal>:print</literal>.  The <literal>:force</literal> command
@@ -1071,7 +1162,8 @@ 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 +1226,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
@@ -1160,10 +1252,14 @@ right :: [a]
 
       <para>Single-stepping is a great way to visualise the execution of your
         program, and it is also a useful tool for identifying the source of a
 
       <para>Single-stepping is a great way to visualise the execution of your
         program, and it is also a useful tool for identifying the source of a
-        bug.  The concept is simple: single-stepping enables all the
-        breakpoints in the program and executes until the next breakpoint is
-        reached, at which point you can single-step again, or continue
-        normally.  For example:</para>
+        bug. GHCi offers two variants of stepping. Use 
+       <literal>:step</literal>  to enable all the
+        breakpoints in the program, and execute until the next breakpoint is
+        reached. Use <literal>:steplocal</literal> to limit the set
+       of enabled breakpoints to those in the current top level function.
+       Similarly, use <literal>:stepmodule</literal> to single step only on
+       breakpoints contained in the current module.
+       For example:</para>
 
 <screen>
 *Main> :step main
 
 <screen>
 *Main> :step main
@@ -1172,10 +1268,11 @@ _result :: IO ()
 </screen>
 
       <para>The command <literal>:step
 </screen>
 
       <para>The command <literal>:step
-          <replaceable>expr</replaceable></literal> begins the evaluation of
+        <replaceable>expr</replaceable></literal> begins the evaluation of
         <replaceable>expr</replaceable> in single-stepping mode.  If
         <replaceable>expr</replaceable> in single-stepping mode.  If
-        <replaceable>expr</replaceable> is ommitted, then it single-steps from
-        the current breakpoint.</para>
+        <replaceable>expr</replaceable> is omitted, then it single-steps from
+        the current breakpoint. <literal>:stepover</literal> 
+        works similarly.</para>
 
       <para>The <literal>:list</literal> command is particularly useful when
         single-stepping, to see where you currently are:</para>
 
       <para>The <literal>:list</literal> command is particularly useful when
         single-stepping, to see where you currently are:</para>
@@ -1373,7 +1470,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
@@ -1382,16 +1481,20 @@ a :: a
         <literal>:trace</literal> and <literal>:history</literal> to establish
         the context.  However, <literal>head</literal> is in a library and
         we can't set a breakpoint on it directly.  For this reason, GHCi
         <literal>:trace</literal> and <literal>:history</literal> to establish
         the context.  However, <literal>head</literal> is in a library and
         we can't set a breakpoint on it directly.  For this reason, GHCi
-        provides the flag <literal>-fbreak-on-exception</literal> which causes
-        the evaluator to stop when an exception is thrown, just as it does when
-        a breakpoint is hit.  This is only really useful in conjunction with
+        provides the flags <literal>-fbreak-on-exception</literal> which causes
+        the evaluator to stop when an exception is thrown, and <literal>
+       -fbreak-on-error</literal>, which works similarly but stops only on 
+       uncaught exceptions. When stopping at an exception, GHCi will act 
+       just as it does when a breakpoint is hit, with the deviation that it
+       will not show you any source code location. Due to this, these 
+       commands are only really useful in conjunction with
         <literal>:trace</literal>, in order to log the steps leading up to the
         exception.  For example:</para>
 
 <screen>
 *Main> :set -fbreak-on-exception
 *Main> :trace qsort ("abc" ++ undefined)
         <literal>:trace</literal>, in order to log the steps leading up to the
         exception.  For example:</para>
 
 <screen>
 *Main> :set -fbreak-on-exception
 *Main> :trace qsort ("abc" ++ undefined)
-"Stopped at &lt;exception thrown&gt;
+&ldquo;Stopped at &lt;exception thrown&gt;
 _exception :: e
 [&lt;exception thrown&gt;] *Main&gt; :hist
 -1  : qsort.hs:3:24-38
 _exception :: e
 [&lt;exception thrown&gt;] *Main&gt; :hist
 -1  : qsort.hs:3:24-38
@@ -1437,7 +1540,7 @@ as = 'b' : 'c' : (_t1::[Char])
 <programlisting>
 import Prelude hiding (map)
 
 <programlisting>
 import Prelude hiding (map)
 
-map :: (a->b) -> a -> b
+map :: (a->b) -> [a] -> [b]
 map f [] = []
 map f (x:xs) = f x : map f xs
 </programlisting>
 map f [] = []
 map f (x:xs) = f x : map f xs
 </programlisting>
@@ -1540,7 +1643,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 +1671,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 +1687,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> 
@@ -1683,13 +1779,16 @@ $ ghci -lm
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
-          <literal>:add</literal> <replaceable>module</replaceable> ...
+          <literal>:add</literal> <optional><literal>*</literal></optional><replaceable>module</replaceable> ...
           <indexterm><primary><literal>:add</literal></primary></indexterm>
         </term>
        <listitem>
          <para>Add <replaceable>module</replaceable>(s) to the
          current <firstterm>target set</firstterm>, and perform a
           <indexterm><primary><literal>:add</literal></primary></indexterm>
         </term>
        <listitem>
          <para>Add <replaceable>module</replaceable>(s) to the
          current <firstterm>target set</firstterm>, and perform a
-         reload.</para>
+         reload.  Normally pre-compiled code for the module will be
+         loaded if available, or otherwise the module will be
+         compiled to byte-code.  Using the <literal>*</literal>
+         prefix forces the module to be loaded as byte-code.</para>
        </listitem>
       </varlistentry>
 
        </listitem>
       </varlistentry>
 
@@ -1721,22 +1820,58 @@ $ ghci -lm
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
-          <literal>:browse</literal> <optional><literal>*</literal></optional><replaceable>module</replaceable> ...
+          <literal>:browse</literal><optional><literal>!</literal></optional> <optional><optional><literal>*</literal></optional><replaceable>module</replaceable></optional> ...
           <indexterm><primary><literal>:browse</literal></primary></indexterm>
         </term>
        <listitem>
          <para>Displays the identifiers defined by the module
          <replaceable>module</replaceable>, which must be either
           <indexterm><primary><literal>:browse</literal></primary></indexterm>
         </term>
        <listitem>
          <para>Displays the identifiers defined by the module
          <replaceable>module</replaceable>, which must be either
-         loaded into GHCi or be a member of a package.  If the
-         <literal>*</literal> symbol is placed before the module
-         name, then <emphasis>all</emphasis> the identifiers defined
-         in <replaceable>module</replaceable> are shown; otherwise
-         the list is limited to the exports of
+         loaded into GHCi or be a member of a package.  If
+         <replaceable>module</replaceable> is omitted, the most
+         recently-loaded module is used.</para>
+
+          <para>If the <literal>*</literal> symbol is placed before
+         the module name, then <emphasis>all</emphasis> the
+         identifiers in scope in <replaceable>module</replaceable> are
+         shown; otherwise the list is limited to the exports of
          <replaceable>module</replaceable>.  The
          <literal>*</literal>-form is only available for modules
          which are interpreted; for compiled modules (including
          modules from packages) only the non-<literal>*</literal>
          <replaceable>module</replaceable>.  The
          <literal>*</literal>-form is only available for modules
          which are interpreted; for compiled modules (including
          modules from packages) only the non-<literal>*</literal>
-         form of <literal>:browse</literal> is available.</para>
+    form of <literal>:browse</literal> is available.
+    If the <literal>!</literal> symbol is appended to the
+    command, data constructors and class methods will be 
+    listed individually, otherwise, they will only be listed
+    in the context of their data type or class declaration. 
+    The <literal>!</literal>-form also annotates the listing 
+    with comments giving possible imports for each group of 
+    entries.</para>
+<screen>
+Prelude> :browse! Data.Maybe
+-- not currently imported
+Data.Maybe.catMaybes :: [Maybe a] -> [a]
+Data.Maybe.fromJust :: Maybe a -> a
+Data.Maybe.fromMaybe :: a -> Maybe a -> a
+Data.Maybe.isJust :: Maybe a -> Bool
+Data.Maybe.isNothing :: Maybe a -> Bool
+Data.Maybe.listToMaybe :: [a] -> Maybe a
+Data.Maybe.mapMaybe :: (a -> Maybe b) -> [a] -> [b]
+Data.Maybe.maybeToList :: Maybe a -> [a]
+-- imported via Prelude
+Just :: a -> Maybe a
+data Maybe a = Nothing | Just a
+Nothing :: Maybe a
+maybe :: b -> (a -> b) -> Maybe a -> b
+</screen>
+  <para>
+    This output shows that, in the context of the current session, in the scope
+    of <literal>Prelude</literal>, the first group of items from
+    <literal>Data.Maybe</literal> have not been imported (but are available in
+    fully qualified form in the GHCi session - see <xref
+      linkend="ghci-scope"/>), whereas the second group of items have been
+    imported via <literal>Prelude</literal> and are therefore available either
+    unqualified, or with a <literal>Prelude.</literal> qualifier.
+  </para>
        </listitem>
       </varlistentry>
 
        </listitem>
       </varlistentry>
 
@@ -1763,16 +1898,6 @@ $ ghci -lm
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
-          <literal>:continue</literal> 
-          <indexterm><primary><literal>:continue</literal></primary></indexterm>
-        </term>
-       <listitem><para>Continue the current evaluation, when stopped at a
-            breakpoint.</para>
-       </listitem>
-      </varlistentry>
-
-      <varlistentry>
-       <term>
           <literal>:cmd</literal> <replaceable>expr</replaceable>
           <indexterm><primary><literal>:cmd</literal></primary></indexterm>
         </term>
           <literal>:cmd</literal> <replaceable>expr</replaceable>
           <indexterm><primary><literal>:cmd</literal></primary></indexterm>
         </term>
@@ -1787,6 +1912,16 @@ $ ghci -lm
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+          <literal>:continue</literal> 
+          <indexterm><primary><literal>:continue</literal></primary></indexterm>
+        </term>
+       <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>
          <literal>:ctags</literal> <optional><replaceable>filename</replaceable></optional>
          <literal>:etags</literal> <optional><replaceable>filename</replaceable></optional>
          <indexterm><primary><literal>:etags</literal></primary>
@@ -1796,8 +1931,9 @@ $ ghci -lm
        </term>
        <listitem>
          <para>Generates a &ldquo;tags&rdquo; file for Vi-style editors
        </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
+           (<literal>:ctags</literal>) or
+        Emacs-style editors (<literal>:etags</literal>).  If
+           no filename is specified, the default <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
            <filename>TAGS</filename> is
            used, respectively.  Tags for all the functions, constructors and
            types in the currently loaded modules are created.  All modules must
@@ -1808,26 +1944,27 @@ $ ghci -lm
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
-          <literal>:def</literal> <replaceable>name</replaceable> <replaceable>expr</replaceable>
+          <literal>:def<optional>!</optional> <optional><replaceable>name</replaceable> <replaceable>expr</replaceable></optional></literal>
           <indexterm><primary><literal>:def</literal></primary></indexterm>
         </term>
        <listitem>
           <indexterm><primary><literal>:def</literal></primary></indexterm>
         </term>
        <listitem>
-         <para>The command <literal>:def</literal>
-         <replaceable>name</replaceable>
-         <replaceable>expr</replaceable> defines a new GHCi command
-         <literal>:<replaceable>name</replaceable></literal>,
-         implemented by the Haskell expression
-         <replaceable>expr</replaceable>, which must have type
-         <literal>String -> IO String</literal>.  When
-         <literal>:<replaceable>name</replaceable>
-         <replaceable>args</replaceable></literal> is typed at the
-         prompt, GHCi will run the expression
-         <literal>(<replaceable>name</replaceable>
-         <replaceable>args</replaceable>)</literal>, take the
-         resulting <literal>String</literal>, and feed it back into
-         GHCi as a new sequence of commands.  Separate commands in
-         the result must be separated by
-         &lsquo;<literal>\n</literal>&rsquo;.</para>
+          <para><literal>:def</literal> is used to define new
+          commands, or macros, in GHCi.  The command
+          <literal>:def</literal> <replaceable>name</replaceable>
+          <replaceable>expr</replaceable> defines a new GHCi command
+          <literal>:<replaceable>name</replaceable></literal>,
+          implemented by the Haskell expression
+          <replaceable>expr</replaceable>, which must have type
+          <literal>String -> IO String</literal>.  When
+          <literal>:<replaceable>name</replaceable>
+          <replaceable>args</replaceable></literal> is typed at the
+          prompt, GHCi will run the expression
+          <literal>(<replaceable>name</replaceable>
+          <replaceable>args</replaceable>)</literal>, take the
+          resulting <literal>String</literal>, and feed it back into
+          GHCi as a new sequence of commands.  Separate commands in
+          the result must be separated by
+          &lsquo;<literal>\n</literal>&rsquo;.</para>
 
          <para>That's all a little confusing, so here's a few
          examples.  To start with, here's a new GHCi command which
 
          <para>That's all a little confusing, so here's a few
          examples.  To start with, here's a new GHCi command which
@@ -1871,6 +2008,12 @@ Prelude> :. cmds.ghci
           <literal>:.</literal>, by analogy with the
           &lsquo;<literal>.</literal>&rsquo; Unix shell command that
           does the same thing.</para>
           <literal>:.</literal>, by analogy with the
           &lsquo;<literal>.</literal>&rsquo; Unix shell command that
           does the same thing.</para>
+
+          <para>Typing <literal>:def</literal> on its own lists the
+          currently-defined macros.  Attempting to redefine an
+          existing command name results in an error unless the
+          <literal>:def!</literal> form is used, in which case the old
+          command with that name is silently overwritten.</para>
        </listitem>
       </varlistentry>
 
        </listitem>
       </varlistentry>
 
@@ -1904,6 +2047,15 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
+          <literal>:etags</literal> 
+        </term>
+       <listitem>
+         <para>See <literal>:ctags</literal>.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
           <literal>:force <replaceable>identifier</replaceable> ...</literal>
           <indexterm><primary><literal>:force</literal></primary></indexterm>
         </term>
           <literal>:force <replaceable>identifier</replaceable> ...</literal>
           <indexterm><primary><literal>:force</literal></primary></indexterm>
         </term>
@@ -1945,6 +2097,17 @@ Prelude> :. cmds.ghci
       </varlistentry>
 
       <varlistentry>
       </varlistentry>
 
       <varlistentry>
+       <term>
+          <literal>:</literal>
+          <indexterm><primary><literal>:</literal></primary></indexterm>
+        </term>
+       <listitem>
+         <para>Repeat the previous command.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+
        <term>
           <literal>:history [<replaceable>num</replaceable>]</literal>
           <indexterm><primary><literal>:history</literal></primary></indexterm>
        <term>
           <literal>:history [<replaceable>num</replaceable>]</literal>
           <indexterm><primary><literal>:history</literal></primary></indexterm>
@@ -1972,6 +2135,12 @@ Prelude> :. cmds.ghci
          will be printed.  If <replaceable>name</replaceable> has
          been loaded from a source file, then GHCi will also display
          the location of its definition in the source.</para>
          will be printed.  If <replaceable>name</replaceable> has
          been loaded from a source file, then GHCi will also display
          the location of its definition in the source.</para>
+         <para>For types and classes, GHCi also summarises instances that
+         mention them.  To avoid showing irrelevant information, an instance
+         is shown only if (a) its head mentions <replaceable>name</replaceable>, 
+         and (b) all the other things mentioned in the instance
+         are in scope (either qualified or otherwise) as a result of 
+         a <literal>:load</literal> or <literal>:module</literal> commands. </para>
        </listitem>
       </varlistentry>
 
        </listitem>
       </varlistentry>
 
@@ -1990,7 +2159,7 @@ Prelude> :. cmds.ghci
 
       <varlistentry>
        <term>
 
       <varlistentry>
        <term>
-          <literal>:load</literal> <replaceable>module</replaceable> ...
+          <literal>:load</literal> <optional><literal>*</literal></optional><replaceable>module</replaceable> ...
           <indexterm><primary><literal>:load</literal></primary></indexterm>
         </term>
        <listitem>
           <indexterm><primary><literal>:load</literal></primary></indexterm>
         </term>
        <listitem>
@@ -2007,6 +2176,11 @@ Prelude> :. cmds.ghci
          to unload all the currently loaded modules and
          bindings.</para>
 
          to unload all the currently loaded modules and
          bindings.</para>
 
+          <para>Normally pre-compiled code for a module will be loaded
+         if available, or otherwise the module will be compiled to
+         byte-code.  Using the <literal>*</literal> prefix forces a
+         module to be loaded as byte-code.</para>
+
          <para>After a <literal>:load</literal> command, the current
          context is set to:</para>
 
          <para>After a <literal>:load</literal> command, the current
          context is set to:</para>
 
@@ -2040,7 +2214,7 @@ Prelude> :. cmds.ghci
             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
             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.
+            arguments directly.
           </para>
 
           <para>
           </para>
 
           <para>
@@ -2056,6 +2230,37 @@ Prelude> :main foo bar
 ["foo","bar"]
 </screen>
 
 ["foo","bar"]
 </screen>
 
+        <para>
+            We can also quote arguments which contains characters like
+            spaces, and they are treated like Haskell strings, or we can
+            just use Haskell list syntax:
+        </para>
+
+<screen>
+Prelude> :main foo "bar baz"
+["foo","bar baz"]
+Prelude> :main ["foo", "bar baz"]
+["foo","bar baz"]
+</screen>
+
+        <para>
+            Finally, other functions can be called, either with the
+            <literal>-main-is</literal> flag or the <literal>:run</literal>
+            command:
+        </para>
+
+<screen>
+Prelude> let foo = putStrLn "foo" >> System.Environment.getArgs >>= print
+Prelude> let bar = putStrLn "bar" >> System.Environment.getArgs >>= print
+Prelude> :set -main-is foo
+Prelude> :main foo "bar baz"
+foo
+["foo","bar baz"]
+Prelude> :run bar ["foo", "bar baz"]
+bar
+["foo","bar baz"]
+</screen>
+
         </listitem>
       </varlistentry>
 
         </listitem>
       </varlistentry>
 
@@ -2064,9 +2269,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>
@@ -2079,7 +2290,7 @@ Prelude> :main foo bar
        <listitem>
          <para>Prints a value without forcing its evaluation.
             <literal>:print</literal> may be used on values whose types are
        <listitem>
          <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
+            unknown 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
             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
@@ -2099,7 +2310,7 @@ Prelude> :main foo bar
           <indexterm><primary><literal>:quit</literal></primary></indexterm>
         </term>
        <listitem>
           <indexterm><primary><literal>:quit</literal></primary></indexterm>
         </term>
        <listitem>
-         <para>Quits GHCi.  You can also quit by typing a control-D
+         <para>Quits GHCi.  You can also quit by typing control-D
          at the prompt.</para>
        </listitem>
       </varlistentry>
          at the prompt.</para>
        </listitem>
       </varlistentry>
@@ -2124,10 +2335,11 @@ Prelude> :main foo bar
           <indexterm><primary><literal>:set</literal></primary></indexterm>
         </term>
        <listitem>
           <indexterm><primary><literal>:set</literal></primary></indexterm>
         </term>
        <listitem>
-         <para>Sets various options.  See <xref linkend="ghci-set"/>
-         for a list of available options.  The
-         <literal>:set</literal> command by itself shows which
-         options are currently set.</para>
+    <para>Sets various options.  See <xref linkend="ghci-set"/> for a list of
+      available options and <xref linkend="interactive-mode-options"/> for a
+      list of GHCi-specific flags.  The <literal>:set</literal> command by
+      itself shows which options are currently set. It also lists the current
+      dynamic flag settings, with GHCi-specific flags listed separately.</para>
        </listitem>
       </varlistentry>
 
        </listitem>
       </varlistentry>
 
@@ -2174,7 +2386,9 @@ Prelude> :main foo bar
          Inside <replaceable>prompt</replaceable>, the sequence
          <literal>%s</literal> is replaced by the names of the
          modules currently in scope, and <literal>%%</literal> is
          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>
+         replaced by <literal>%</literal>. If <replaceable>prompt</replaceable>
+      starts with &quot; then it is parsed as a Haskell String;
+      otherwise it is treated as a literal string.</para>
         </listitem>
       </varlistentry>
 
         </listitem>
       </varlistentry>
 
@@ -2244,12 +2458,34 @@ Prelude> :main foo bar
           <indexterm><primary><literal>:show modules</literal></primary></indexterm>
         </term>
        <listitem>
           <indexterm><primary><literal>:show modules</literal></primary></indexterm>
         </term>
        <listitem>
-         <para>Show the list of modules currently load.</para>
+         <para>Show the list of modules currently loaded.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>
+          <literal>:show packages</literal>
+          <indexterm><primary><literal>:show packages</literal></primary></indexterm>
+        </term>
+       <listitem>
+    <para>Show the currently active package flags, as well as the list of
+      packages currently loaded.</para>
        </listitem>
       </varlistentry>
 
       <varlistentry>
        <term>
        </listitem>
       </varlistentry>
 
       <varlistentry>
        <term>
+          <literal>:show languages</literal>
+          <indexterm><primary><literal>:show languages</literal></primary></indexterm>
+        </term>
+       <listitem>
+    <para>Show the currently active language flags.</para>
+       </listitem>
+      </varlistentry>
+
+
+      <varlistentry>
+       <term>
           <literal>:show [args|prog|prompt|editor|stop]</literal>
           <indexterm><primary><literal>:show</literal></primary></indexterm>
         </term>
           <literal>:show [args|prog|prompt|editor|stop]</literal>
           <indexterm><primary><literal>:show</literal></primary></indexterm>
         </term>
@@ -2355,7 +2591,7 @@ Prelude> :main foo bar
 
     <para>The <literal>:set</literal> command sets two types of
     options: GHCi options, which begin with
 
     <para>The <literal>:set</literal> command sets two types of
     options: GHCi options, which begin with
-    &lsquo;<literal>+</literal>&rdquo; and &ldquo;command-line&rdquo;
+    &lsquo;<literal>+</literal>&rsquo;, and &ldquo;command-line&rdquo;
     options, which begin with &lsquo;-&rsquo;.  </para>
 
     <para>NOTE: at the moment, the <literal>:set</literal> command
     options, which begin with &lsquo;-&rsquo;.  </para>
 
     <para>NOTE: at the moment, the <literal>:set</literal> command
@@ -2467,18 +2703,35 @@ Prelude> :set -fno-glasgow-exts
     <indexterm><primary>startup</primary><secondary>files, GHCi</secondary>
     </indexterm>
 
     <indexterm><primary>startup</primary><secondary>files, GHCi</secondary>
     </indexterm>
 
-    <para>When it starts, GHCi always reads and executes commands from
-    <filename>$HOME/.ghci</filename>, followed by
-    <filename>./.ghci</filename>.</para>
-
-    <para>The <filename>.ghci</filename> in your home directory is
-    most useful for turning on favourite options (eg. <literal>:set
-    +s</literal>), and defining useful macros.  Placing a
-    <filename>.ghci</filename> file in a directory with a Haskell
-    project is a useful way to set certain project-wide options so you
-    don't have to type them everytime you start GHCi: eg. if your
-    project uses GHC extensions and CPP, and has source files in three
-    subdirectories A B and C, you might put the following lines in
+    <para>When it starts, unless the <literal>-ignore-dot-ghci</literal>
+    flag is given, GHCi reads and executes commands from the following
+    files, in this order, if they exist:</para>
+
+    <orderedlist>
+    <listitem>
+      <para><filename>./.ghci</filename></para>
+    </listitem>
+    <listitem>
+      <para><literal><replaceable>appdata</replaceable>/ghc/ghci.conf</literal>,
+      where <replaceable>appdata</replaceable> depends on your system,
+      but is usually something like <literal>C:/Documents and Settings/<replaceable>user</replaceable>/Application Data</literal></para>
+    </listitem>
+    <listitem>
+      <para>On Unix: <literal>$HOME/.ghc/ghci.conf</literal></para>
+    </listitem>
+    <listitem>
+      <para><literal>$HOME/.ghci</literal></para>
+    </listitem>
+   </orderedlist>
+
+    <para>The <filename>ghci.conf</filename> file is most useful for
+    turning on favourite options (eg. <literal>:set +s</literal>), and
+    defining useful macros.  Placing a <filename>.ghci</filename> file
+    in a directory with a Haskell project is a useful way to set
+    certain project-wide options so you don't have to type them
+    everytime you start GHCi: eg. if your project uses GHC extensions
+    and CPP, and has source files in three subdirectories A, B and C,
+    you might put the following lines in
     <filename>.ghci</filename>:</para>
 
 <screen>
     <filename>.ghci</filename>:</para>
 
 <screen>
@@ -2491,8 +2744,24 @@ Prelude> :set -fno-glasgow-exts
     <literal>:set</literal> like this.  The changes won't take effect
     until the next <literal>:load</literal>, though.)</para>
 
     <literal>:set</literal> like this.  The changes won't take effect
     until the next <literal>:load</literal>, though.)</para>
 
+    <para>Once you have a library of GHCi macros, you may want
+    to source them from separate files, or you may want to source
+    your <filename>.ghci</filename> file into your running GHCi
+    session while debugging it</para>
+
+<screen>
+:def source readFile
+</screen>
+
+    <para>With this macro defined in your <filename>.ghci</filename> 
+    file, you can use <literal>:source file</literal> to read GHCi
+    commands from <literal>file</literal>. You can find (and contribute!-)
+    other suggestions for <filename>.ghci</filename> files on this Haskell
+    wiki page: <ulink
+      url="http://haskell.org/haskellwiki/GHC/GHCi">GHC/GHCi</ulink></para>
+
     <para>Two command-line options control whether the
     <para>Two command-line options control whether the
-    <filename>.ghci</filename> files are read:</para>
+    startup files files are read:</para>
 
     <variablelist>
       <varlistentry>
 
     <variablelist>
       <varlistentry>
@@ -2501,8 +2770,8 @@ Prelude> :set -fno-glasgow-exts
           <indexterm><primary><option>-ignore-dot-ghci</option></primary></indexterm>
         </term>
        <listitem>
           <indexterm><primary><option>-ignore-dot-ghci</option></primary></indexterm>
         </term>
        <listitem>
-         <para>Don't read either <filename>./.ghci</filename> or
-         <filename>$HOME/.ghci</filename> when starting up.</para>
+         <para>Don't read either <filename>./.ghci</filename> or the
+          other startup files when starting up.</para>
        </listitem>
       </varlistentry>
       <varlistentry>
        </listitem>
       </varlistentry>
       <varlistentry>
@@ -2511,8 +2780,8 @@ Prelude> :set -fno-glasgow-exts
           <indexterm><primary><option>-read-dot-ghci</option></primary></indexterm>
         </term>
        <listitem>
           <indexterm><primary><option>-read-dot-ghci</option></primary></indexterm>
         </term>
        <listitem>
-         <para>Read <filename>.ghci</filename> and
-         <filename>$HOME/.ghci</filename>.  This is normally the
+         <para>Read <filename>./.ghci</filename> and the other
+          startup files (see above).  This is normally the
          default, but the <option>-read-dot-ghci</option> option may
          be used to override a previous
          <option>-ignore-dot-ghci</option> option.</para>
          default, but the <option>-read-dot-ghci</option> option may
          be used to override a previous
          <option>-ignore-dot-ghci</option> option.</para>
@@ -2626,7 +2895,19 @@ Prelude> :set -fno-glasgow-exts
        <term>I can't use Control-C to interrupt computations in
           GHCi on Windows.</term>
         <listitem>
        <term>I can't use Control-C to interrupt computations in
           GHCi on Windows.</term>
         <listitem>
-          <para>See <xref linkend="ghci-windows"/></para>
+          <para>See <xref linkend="ghci-windows"/>.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term>The default buffering mode is different in GHCi to GHC.</term>
+        <listitem>
+          <para>
+            In GHC, the stdout handle is line-buffered by default.
+            However, in GHCi we turn off the buffering on stdout,
+            because this is normally what you want in an interpreter:
+            output appears as it is generated.
+          </para>
         </listitem>
       </varlistentry>
     </variablelist>
         </listitem>
       </varlistentry>
     </variablelist>