<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 C ( C.hs, interpreted )
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
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>
*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>
*Main> :! ghc -c C.hs
*Main> :load A
Compiling D ( D.hs, interpreted )
-Compiling C ( C.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>
<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.
when working on a large program is to occasionally run
<literal>ghc ––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>
<para>
Hint: GHCi will tab-complete names that are in scope; for
example, if you run GHCi and type <literal>J<tab></literal>
- then GHCi will expand it to <literal>Just </literal>.
+ then GHCi will expand it to “<literal>Just </literal>”.
</para>
<sect3>
</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>
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>
<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
<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>Listing and deleting breakpoints</title>
<para>The list of breakpoints currently enabled can be displayed using
- <literal>:show breaks</literal></para>:
+ <literal>:show breaks</literal>:</para>
<screen>
*Main> :show breaks
[0] Main qsort.hs:1:11-12
</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>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>
<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>
<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>
<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>
</term>
<listitem>
<para>Generates a “tags” file for Vi-style editors
- (<literal>:ctags</literal>) or Emacs-style editors (<literal>etags</literal>). If
+ (<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
<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>
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>
<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
<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>
<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>
<para>The <literal>:set</literal> command sets two types of
options: GHCi options, which begin with
- ‘<literal>+</literal>” and “command-line”
+ ‘<literal>+</literal>’, and “command-line”
options, which begin with ‘-’. </para>
<para>NOTE: at the moment, the <literal>:set</literal> command
<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>When it starts, unless the <literal>-ignore-dot-ghci</literal>
+ flag is given, GHCi reads and executes commands from
+ <filename>./.ghci</filename>, followed by
+ <filename>$HOME/.ghci</filename>.</para>
<para>The <filename>.ghci</filename> in your home directory is
most useful for turning on favourite options (eg. <literal>:set
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
+ subdirectories A, B and C, you might put the following lines in
<filename>.ghci</filename>:</para>
<screen>
<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>
</variablelist>