Prelude> head li
Just 1
Prelude> :sp li
-li - [Just 1 | _]
+li - Just 1 : _
Prelude> :p li
-li - [Just 1 | (_t2::[Maybe Integer])]
+li - Just 1 : (_t2::[Maybe Integer])
Prelude> last li
Just 5
Prelude> :sp li
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>Finally note that the Prolog convention of [head | tail] is used by
- <literal>:sprint</literal> to display unevaluated lists.
</para>
</listitem>
</varlistentry>
Prelude> head li
Just 1
Prelude> :sp li
-li - [Just 1 | _]
+li - Just 1 : _
Prelude> last li
Just 5
Prelude> :sp li
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>Finally note that the Prolog convention of [head | tail] is used by
- <literal>:sprint</literal> to display unevaluated lists.
</para>
</listitem>
</varlistentry>
Note that a wrong coercion will likely result in your debugging session being interrupted by a segmentation fault
</para></listitem>
</varlistentry>
- <varlistentry> <term> * The undocumented (and unsupported) :force command </term>
+ <varlistentry> <term> * The <literal>:force</literal> command </term>
<listitem><para>
equivalent to <literal> :print</literal> with automatic
<literal>seq</literal> forcing,
</sect1>
+ <sect1 id="ghci-obj">
+ <title>Compiling to object code inside GHCi</title>
+
+ <para>By default, GHCi compiles Haskell source code into byte-code
+ that is interpreted by the runtime system. GHCi can also compile
+ Haskell code to object code: to turn on this feature, use the
+ <option>-fobject-code</option> flag either on the command line or
+ with <literal>:set</literal> (the option
+ <option>-fbyte-code</option> restores byte-code compilation
+ again). Compiling to object code takes longer, but typically the
+ code will execute 10-20 times faster than byte-code.</para>
+
+ <para>Compiling to object code inside GHCi is particularly useful
+ if you are developing a compiled application, because the
+ <literal>:reload</literal> command typically runs much faster than
+ restarting GHC with <option>--make</option> from the command-line,
+ because all the interface files are already cached in
+ memory.</para>
+
+ <para>There are disadvantages to compiling to object-code: you
+ can't set breakpoints in object-code modules, for example. Only
+ the exports of an object-code module will be visible in GHCi,
+ rather than all top-level bindings as in interpreted
+ modules.</para>
+ </sect1>
+
<sect1 id="ghci-faq">
<title>FAQ and Things To Watch Out For</title>