5743d89510a83c497c0c3a5d7dc5056ebd8513f9
[ghc-hetmet.git] / ghc / docs / users_guide / ghci.sgml
1 <chapter id="ghci">
2   <title>Using GHCi</title>
3   <indexterm><primary>GHCi</primary></indexterm>
4   <indexterm><primary>interpreter</primary><see>GHCi</see></indexterm>
5   <indexterm><primary>interactive</primary><see>GHCi</see></indexterm>
6   
7   <para>GHCi<footnote>
8       <para>The &lsquo;i&rsquo; stands for &ldquo;Interactive&rdquo;</para>
9     </footnote>
10   is GHC's interactive environment, in which Haskell expressions can
11   be interactively evaluated and programs can be interpreted.  If
12   you're famililar with Hugs<indexterm><primary>Hugs</primary>
13   </indexterm>, then you'll be right at home with GHCi.  However, GHCi
14   also has support for interactively loading compiled code, as well as
15   supporting all<footnote><para>except <literal>foreign export</literal>, at the moment</para>
16   </footnote>the language extensions that GHC provides.</para>
17   <indexterm><primary>FFI</primary><secondary>GHCi support</secondary></indexterm>
18   <indexterm><primary>Foreign Function Interface</primary><secondary>GHCi support</secondary></indexterm>
19
20   <sect1>
21     <title>Introduction to GHCi</title>
22
23     <para>Let's start with an example GHCi session.  You can fire up
24     GHCi with the command <literal>ghci</literal>:</para>
25
26 <screen>
27 $ ghci
28    ___         ___ _
29   / _ \ /\  /\/ __(_)
30  / /_\// /_/ / /  | |      GHC Interactive, version 5.00, For Haskell 98.
31 / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
32 \____/\/ /_/\____/|_|      Type :? for help.
33
34 Loading package std ... linking ... done.
35 Prelude> 
36 </screen>
37
38     <para>There may be a short pause while GHCi loads the prelude and
39     standard libraries, after which the prompt is shown.  If we follow
40     the instructions and type <literal>:?</literal> for help, we
41     get:</para>
42
43 <screen>
44  Commands available from the prompt:
45    &lt;stmt&gt;              evaluate/run &lt;stmt&gt;
46    :cd &lt;dir&gt;           change directory to &lt;dir&gt;
47    :def &lt;cmd&gt; &lt;expr&gt;   define a macro :&lt;cmd&gt;
48    :help, :?           display this list of commands
49    :load &lt;filename&gt;    load a module (and it dependents)
50    :module &lt;mod&gt;       set the context for expression evaluation to &lt;mod&gt;
51    :reload             reload the current module set
52    :set &lt;option&gt; ...   set options
53    :type &lt;expr&gt;        show the type of &lt;expr&gt;
54    :unset &lt;option&gt; ... unset options
55    :quit               exit GHCi
56    :!&lt;command&gt;         run the shell command &lt;command&gt;
57  Options for `:set' and `:unset':
58     +r                 revert top-level expressions after each evaluation
59     +s                 print timing/memory stats after each evaluation
60     +t                 print type after evaluation
61     -&lt;flag&gt;            most GHC command line flags can also be set here
62                          (eg. -v2, -fglasgow-exts, etc.)
63 </screen>
64
65     <para>We'll explain most of these commands as we go along.  For
66     Hugs users: many things work the same as in Hugs, so you should be
67     able to get going straight away.</para>
68
69     <para>Haskell expressions can be typed at the prompt:</para>
70     <indexterm><primary>prompt</primary><secondary>GHCi</secondary>
71   </indexterm>
72
73 <screen>
74 Prelude> 1+2
75 3
76 Prelude> let x = 42 in x / 9
77 4.666666666666667
78 Prelude> 
79 </screen>
80
81     <para>GHCi interprets the whole line as an expression to evaluate.
82     The expression may not span several lines - as soon as you press
83     enter, GHCi will attempt to evaluate it.</para>
84   </sect1>
85
86   <sect1>
87     <title>Loading source files</title>
88
89     <para>Suppose we have the following Haskell source code, which we
90     place in a file <filename>Main.hs</filename> in the current
91     directory:</para>
92
93 <programlisting>
94 main = print (fac 20)
95
96 fac 0 = 1
97 fac n = n * fac (n-1)
98 </programlisting>
99
100     <para>To load a Haskell source file into GHCi, use the
101     <literal>:load</literal> command:</para>
102     <indexterm><primary><literal>:load</literal></primary></indexterm>
103
104 <screen>
105 Prelude> :load Main
106 Compiling Main             ( Main.hs, interpreted )
107 Ok, modules loaded: Main.
108 *Main>
109 </screen>
110
111     <para>GHCi has loaded the <literal>Main</literal> module, and the
112     prompt has changed to &ldquo;<literal>*Main></literal>&rdquo; to
113     indicate that the current context for expressions typed at the
114     prompt is the <literal>Main</literal> module we just loaded (we'll
115     explain what the <literal>*</literal> means later in <xref
116     linkend="ghci-scope">).  So we can now type expressions involving
117     the functions from <filename>Main.hs</filename>:</para>
118
119 <screen>
120 *Main> fac 17
121 355687428096000
122 </screen>
123
124     <para>Loading a multi-module program is just as straightforward;
125     just give the name of the &ldquo;topmost&rdquo; module to the
126     <literal>:load</literal> command (hint: <literal>:load</literal>
127     can be abbreviated to <literal>:l</literal>).  The topmost module
128     will normally be <literal>Main</literal>, but it doesn't have to
129     be.  GHCi will discover which modules are required, directly or
130     indirectly, by the topmost module, and load them all in dependency
131     order.</para>
132
133     <sect2>
134       <title>Modules vs. filenames</title>
135       <indexterm><primary>modules</primary><secondary>and filenames</secondary></indexterm>
136       <indexterm><primary>filenames</primary><secondary>of modules</secondary></indexterm>
137       
138       <para>Question: How does GHC find the filename which contains
139       module <replaceable>M</replaceable>?  Answer: it looks for the
140       file <literal><replaceable>M</replaceable>.hs</literal>, or
141       <literal><replaceable>M</replaceable>.lhs</literal>.  This means
142       that for most modules, the module name must match the filename.
143       If it doesn't, GHCi won't be able to find it.</para>
144
145       <para>There is one exception to this general rule: when you load
146       a program with <literal>:load</literal>, or specify it when you
147       invoke <literal>ghci</literal>, you can give a filename rather
148       than a module name.  This filename is loaded if it exists, and
149       it may contain any module you like.  This is particularly
150       convenient if you have several <literal>Main</literal> modules
151       in the same directory and you can't call them all
152       <filename>Main.hs</filename>.</para>
153
154       <para>The search path for finding source files is specified with
155       the <option>-i</option> option on the GHCi command line, like
156       so:</para>
157 <screen>ghci -i<replaceable>dir<subscript>1</subscript></replaceable>:...:<replaceable>dir<subscript>n</subscript></replaceable></screen>
158
159       <para>or it can be set using the <literal>:set</literal> command
160       from within GHCi (see <xref
161       linkend="ghci-cmd-line-options">)<footnote><para>Note that in
162       GHCi, and <option>&ndash;&ndash;make</option> mode, the <option>-i</option>
163       option is used to specify the search path for
164       <emphasis>source</emphasis> files, whereas in standard
165       batch-compilation mode the <option>-i</option> option is used to
166       specify the search path for interface files, see <xref
167       linkend="options-finding-imports">.</para> </footnote></para>
168
169       <para>One consequence of the way that GHCi follows dependencies
170       to find modules to load is that every module must have a source
171       file.  The only exception to the rule is modules that come from
172       a package, including the <literal>Prelude</literal> and standard
173       libraries such as <literal>IO</literal> and
174       <literal>Complex</literal>.  If you attempt to load a module for
175       which GHCi can't find a source file, even if there are object
176       and interface files for the module, you'll get an error
177       message.</para>
178
179       <para>One final note: if you load a module called Main, it must
180       contain a <literal>main</literal> function, just like in
181       GHC.</para>
182     </sect2>
183
184     <sect2>
185       <title>Making changes and recompilation</title>
186       <indexterm><primary><literal>:reload</literal></primary></indexterm>
187
188       <para>If you make some changes to the source code and want GHCi
189       to recompile the program, give the <literal>:reload</literal>
190       command.  The program will be recompiled as necessary, with GHCi
191       doing its best to avoid actually recompiling modules if their
192       external dependencies haven't changed.  This is the same
193       mechanism we use to avoid re-compiling modules in the batch
194       compilation setting (see <xref linkend="recomp">).</para>
195     </sect2>
196   </sect1>
197
198   <sect1 id="ghci-compiled">
199     <title>Loading compiled code</title>
200     <indexterm><primary>compiled code</primary><secondary>in GHCi</secondary></indexterm>
201
202     <para>When you load a Haskell source module into GHCi, it is
203     normally converted to byte-code and run using the interpreter.
204     However, interpreted code can also run alongside compiled code in
205     GHCi; indeed, normally when GHCi starts, it loads up a compiled
206     copy of package <literal>std</literal>, which contains the Prelude
207     and standard libraries.</para>
208
209     <para>Why should we want to run compiled code?  Well, compiled
210     code is roughly 10x faster than interpreted code, but takes about
211     2x longer to produce (perhaps longer if optimisation is on).  So
212     it pays to compile the parts of a program that aren't changing
213     very often, and use the interpreter for the code being actively
214     developed.</para>
215
216     <para>When loading up source files with <literal>:load</literal>,
217     GHCi looks for any corresponding compiled object files, and will
218     use one in preference to interpreting the source if possible.  For
219     example, suppose we have a 4-module program consisting of modules
220     A, B, C, and D.  Modules B and C both import D only,
221     and A imports both B & C:</para>
222 <screen>
223       A
224      / \
225     B   C
226      \ /
227       D
228 </screen>
229     <para>We can compile D, then load the whole program, like this:</para>
230 <screen>
231 Prelude> :! ghc -c D.hs
232 Prelude> :load A
233 Skipping  D                ( D.hs, D.o )
234 Compiling C                ( C.hs, interpreted )
235 Compiling B                ( B.hs, interpreted )
236 Compiling A                ( A.hs, interpreted )
237 Ok, modules loaded: A, B, C, D.
238 *Main>
239 </screen>
240
241     <para>In the messages from the compiler, we see that it skipped D,
242     and used the object file <filename>D.o</filename>.  The message
243     <literal>Skipping</literal> <replaceable>module</replaceable>
244     indicates that compilation for <replaceable>module</replaceable>
245     isn't necessary, because the source and everything it depends on
246     is unchanged since the last compilation.</para>
247
248     <para>At any time you can use the command 
249     <literal>:show modules</literal>
250     to get a list of the modules currently loaded
251     into GHCi:</para>
252
253 <screen>
254 *Main> :show modules
255 D                ( D.hs, D.o )
256 C                ( C.hs, interpreted )
257 B                ( B.hs, interpreted )
258 A                ( A.hs, interpreted )
259 *Main></screen>
260
261     <para>If we now modify the source of D (or pretend to: using Unix
262     command <literal>touch</literal> on the source file is handy for
263     this), the compiler will no longer be able to use the object file,
264     because it might be out of date:</para>
265
266 <screen>
267 *Main> :! touch D.hs
268 *Main> :reload
269 Compiling D                ( D.hs, interpreted )
270 Skipping  C                ( C.hs, interpreted )
271 Skipping  B                ( B.hs, interpreted )
272 Skipping  A                ( A.hs, interpreted )
273 Ok, modules loaded: A, B, C, D.
274 *Main> 
275 </screen>
276
277     <para>Note that module D was compiled, but in this instance
278     because its source hadn't really changed, its interface remained
279     the same, and the recompilation checker determined that A, B and C
280     didn't need to be recompiled.</para>
281
282     <para>So let's try compiling one of the other modules:</para>
283
284 <screen>
285 *Main> :! ghc -c C.hs
286 *Main> :load A
287 Compiling D                ( D.hs, interpreted )
288 Compiling C                ( C.hs, interpreted )
289 Compiling B                ( B.hs, interpreted )
290 Compiling A                ( A.hs, interpreted )
291 Ok, modules loaded: A, B, C, D.
292 </screen>
293
294     <para>We didn't get the compiled version of C!  What happened?
295     Well, in GHCi a compiled module may only depend on other compiled
296     modules, and in this case C depends on D, which doesn't have an
297     object file, so GHCi also rejected C's object file.  Ok, so let's
298     also compile D:</para>
299
300 <screen>
301 *Main> :! ghc -c D.hs
302 *Main> :reload
303 Ok, modules loaded: A, B, C, D.
304 </screen>
305
306     <para>Nothing happened!  Here's another lesson: newly compiled
307     modules aren't picked up by <literal>:reload</literal>, only
308     <literal>:load</literal>:</para>
309
310 <screen>
311 *Main> :load A
312 Skipping  D                ( D.hs, D.o )
313 Skipping  C                ( C.hs, C.o )
314 Compiling B                ( B.hs, interpreted )
315 Compiling A                ( A.hs, interpreted )
316 Ok, modules loaded: A, B, C, D.
317 </screen>
318
319     <para>HINT: since GHCi will only use a compiled object file if it
320     can sure that the compiled version is up-to-date, a good technique
321     when working on a large program is to occasionally run
322     <literal>ghc &ndash;&ndash;make</literal> to compile the whole project (say
323     before you go for lunch :-), then continue working in the
324     interpreter.  As you modify code, the new modules will be
325     interpreted, but the rest of the project will remain
326     compiled.</para>
327
328   </sect1>
329
330   <sect1>
331     <title>Interactive evaluation at the prompt</title>
332
333     <para>When you type an expression at the prompt, GHCi immediately
334     evaluates and prints the result.  But that's not the whole story:
335     if you type something of type <literal>IO a</literal> for some
336     <literal>a</literal>, then GHCi <emphasis>executes</emphasis> it
337     as an IO-computation, and doesn't attempt to print the
338     result:.</para>
339
340 <screen>
341 Prelude> "hello"
342 "hello"
343 Prelude> putStrLn "hello"
344 hello
345 </screen>
346
347     <para>What actually happens is that GHCi typechecks the
348     expression, and if it doesn't have an <literal>IO</literal> type,
349     then it transforms it as follows: an expression
350     <replaceable>e</replaceable> turns into 
351 <screen>     
352              let it = <replaceable>e</replaceable>;
353              print it
354 </screen>
355     which is then run as an IO-action.</para>
356
357     <para>Hence, the original expression must have a type which is an
358     instance of the <literal>Show</literal> class, or GHCi will
359     complain:</para>
360
361 <screen>
362 Prelude> id
363 No instance for `Show (a -> a)'
364 arising from use of `print'
365 in a `do' expression pattern binding: print it
366 </screen>
367
368     <para>The error message contains some clues as to the
369     transformation happening internally.</para>
370
371     <sect2 id="ghci-scope">
372       <title>What's really in scope at the prompt?</title> 
373
374       <para>When you type an expression at the prompt, what
375       identifiers and types are in scope?  GHCi provides a flexible
376       way to control exactly how the context for an expression is
377       constructed.  Let's start with the simple cases; when you start
378       GHCi the prompt looks like this:</para>
379
380 <screen>Prelude></screen>
381
382       <para>Which indicates that everything from the module
383       <literal>Prelude</literal> is currently in scope.  If we now
384       load a file into GHCi, the prompt will change:</para>
385
386 <screen>
387 Prelude> :load Main.hs
388 Compiling Main             ( Main.hs, interpreted )
389 *Main>
390 </screen>
391
392       <para>The new prompt is <literal>*Main</literal>, which
393       indicates that we are typing expressions in the context of the
394       top-level of the <literal>Main</literal> module.  Everything
395       that is in scope at the top-level in the module
396       <literal>Main</literal> we just loaded is also in scope at the
397       prompt (probably including <literal>Prelude</literal>, as long
398       as <literal>Main</literal> doesn't explicitly hide it).</para>
399
400       <para>The syntax
401       <literal>*<replaceable>module</replaceable></literal> indicates
402       that it is the full top-level scope of
403       <replaceable>module</replaceable> that is contributing to the
404       scope for expressions typed at the prompt.  Without the
405       <literal>*</literal>, just the exports of the module are
406       visible.</para>
407
408       <para>We're not limited to a single module: GHCi can combine
409       scopes from multiple modules, in any mixture of
410       <literal>*</literal> and non-<literal>*</literal> forms.  GHCi
411       combines the scopes from all of these modules to form the scope
412       that is in effect at the prompt.  For technical reasons, GHCi
413       can only support the <literal>*</literal>-form for modules which
414       are interpreted, so compiled modules and package modules can
415       only contribute their exports to the current scope.</para>
416
417       <para>The scope is manipulated using the
418       <literal>:module</literal> command.  For example, if the current
419       scope is <literal>Prelude</literal>, then we can bring into
420       scope the exports from the module <literal>IO</literal> like
421       so:</para>
422
423 <screen>
424 Prelude> :module +IO
425 Prelude,IO> hPutStrLn stdout "hello\n"
426 hello
427 Prelude,IO>
428 </screen>
429
430       <para>(Note: <literal>:module</literal> can be shortened to
431       <literal>:m</literal>). The full syntax of the
432       <literal>:module</literal> command is:</para>
433
434 <screen>
435 :module <optional>+|-</optional> <optional>*</optional><replaceable>mod<subscript>1</subscript></replaceable> ... <optional>*</optional><replaceable>mod<subscript>n</subscript></replaceable>
436 </screen>
437
438       <para>Using the <literal>+</literal> form of the
439       <literal>module</literal> commands adds modules to the current
440       scope, and <literal>-</literal> removes them.  Without either
441       <literal>+</literal> or <literal>-</literal>, the current scope
442       is replaced by the set of modules specified.  Note that if you
443       use this form and leave out <literal>Prelude</literal>, GHCi
444       will assume that you really wanted the
445       <literal>Prelude</literal> and add it in for you (if you don't
446       want the <literal>Prelude</literal>, then ask to remove it with
447       <literal>:m -Prelude</literal>).</para>
448
449       <para>The scope is automatically set after a
450       <literal>:load</literal> command, to the most recently loaded
451       "target" module, in a <literal>*</literal>-form if possible.
452       For example, if you say <literal>:load foo.hs bar.hs</literal>
453       and <filename>bar.hs</filename> contains module
454       <literal>Bar</literal>, then the scope will be set to
455       <literal>*Bar</literal> if <literal>Bar</literal> is
456       interpreted, or if <literal>Bar</literal> is compiled it will be
457       set to <literal>Prelude,Bar</literal> (GHCi automatically adds
458       <literal>Prelude</literal> if it isn't present and there aren't
459       any <literal>*</literal>-form modules).</para>
460
461       <para>With multiple modules in scope, especially multiple
462       <literal>*</literal>-form modules, it is likely that name
463       clashes will occur.  Haskell specifies that name clashes are
464       only reported when an ambiguous identifier is used, and GHCi
465       behaves in the same way for expressions typed at the
466       prompt.</para>
467
468       <sect3>
469         <title>Qualified names</title>
470
471         <para>To make life slightly easier, the GHCi prompt also
472         behaves as if there is an implicit <literal>import
473         qualified</literal> declaration for every module in every
474         package, and every module currently loaded into GHCi.</para>
475       </sect3>
476     </sect2>
477   
478     <sect2>
479       <title>Using <literal>do-</literal>notation at the prompt</title>
480       <indexterm><primary>do-notation</primary><secondary>in GHCi</secondary></indexterm>
481       <indexterm><primary>statements</primary><secondary>in GHCi</secondary></indexterm>
482       
483       <para>GHCi actually accepts <firstterm>statements</firstterm>
484       rather than just expressions at the prompt.  This means you can
485       bind values and functions to names, and use them in future
486       expressions or statements.</para>
487
488       <para>The syntax of a statement accepted at the GHCi prompt is
489       exactly the same as the syntax of a statement in a Haskell
490       <literal>do</literal> expression.  However, there's no monad
491       overloading here: statements typed at the prompt must be in the
492       <literal>IO</literal> monad.</para>
493
494       <para>Here's an example:</para>
495 <screen>
496 Prelude> x <- return 42
497 Prelude> print x
498 42
499 Prelude>
500 </screen>
501       <para>The statement <literal>x <- return 42</literal> means
502       &ldquo;execute <literal>return 42</literal> in the
503       <literal>IO</literal> monad, and bind the result to
504       <literal>x</literal>&rdquo;.  We can then use
505       <literal>x</literal> in future statements, for example to print
506       it as we did above.</para>
507
508       <para>Of course, you can also bind normal non-IO expressions
509       using the <literal>let</literal>-statement:</para>
510 <screen>
511 Prelude> let x = 42
512 Prelude> print x
513 42
514 Prelude>
515 </screen>
516       <para>An important difference between the two types of binding
517       is that the monadic bind (<literal>p <- e</literal>) is
518       <emphasis>strict</emphasis> (it evaluates <literal>e</literal>),
519       whereas with the <literal>let</literal> form, the expression
520       isn't evaluated immediately:</para>
521 <screen>
522 Prelude> let x = error "help!"
523 Prelude> print x
524 *** Exception: help!
525 Prelude>
526 </screen>
527       <para>Any exceptions raised during the evaluation or execution
528       of the statement are caught and printed by the GHCi command line
529       interface (see <xref linkend="sec-Exception"> for more
530       information on GHC's Exception support).</para>
531
532       <para>Every new binding shadows any existing bindings of the
533       same name, including entities that are in scope in the current
534       module context.</para>
535
536       <para>WARNING: temporary bindings introduced at the prompt only
537       last until the next <literal>:load</literal> or
538       <literal>:reload</literal> command, at which time they will be
539       simply lost.  However, they do survive a change of context with
540       <literal>:module</literal>: the temporary bindings just move to
541       the new location.</para>
542
543       <para>HINT: To get a list of the bindings currently in scope, use the
544       <literal>:show bindings</literal> command:</para>
545
546 <screen>
547 Prelude> :show bindings
548 x :: Int
549 Prelude></screen>
550
551       <para>HINT: if you turn on the <literal>+t</literal> option,
552       GHCi will show the type of each variable bound by a statement.
553       For example:</para>
554       <indexterm><primary><literal>+t</literal></primary></indexterm>
555 <screen>
556 Prelude> :set +t
557 Prelude> let (x:xs) = [1..]
558 x :: Integer
559 xs :: [Integer]
560 </screen>
561
562     </sect2>
563
564     <sect2>
565       <title>The <literal>it</literal> variable</title>
566       <indexterm><primary><literal>it</literal></primary>
567       </indexterm>
568       
569       <para>Whenever an expression (or a non-binding statement, to be
570       precise) is typed at the prompt, GHCi implicitly binds its value
571       to the variable <literal>it</literal>.  For example:</para>
572 <screen>
573 Prelude> 1+2
574 3
575 Prelude> it * 2
576 6
577 </screen>
578
579       <para>This is a result of the translation mentioned earlier,
580       namely that an expression <replaceable>e</replaceable> is
581       translated to
582 <screen>     
583              let it = <replaceable>e</replaceable>;
584              print it
585 </screen>
586       before execution, resulting in a binding for
587       <literal>it</literal>.</para>
588
589       <para>If the expression was of type <literal>IO a</literal> for
590       some <literal>a</literal>, then <literal>it</literal> will be
591       bound to the result of the <literal>IO</literal> computation,
592       which is of type <literal>a</literal>.  eg.:</para>
593 <screen>
594 Prelude> Time.getClockTime
595 Prelude> print it
596 Wed Mar 14 12:23:13 GMT 2001
597 </screen>
598
599       <para>The corresponding translation for an IO-typed
600       <replaceable>e</replaceable> is
601 <screen>     
602              it <- <replaceable>e</replaceable>
603 </screen>
604       </para>
605
606       <para>Note that <literal>it</literal> is shadowed by the new
607       value each time you evaluate a new expression, and the old value
608       of <literal>it</literal> is lost.</para>
609
610     </sect2>
611   </sect1>
612
613   <sect1 id="ghci-invokation">
614     <title>Invoking GHCi</title>
615     <indexterm><primary>invoking</primary><secondary>GHCi</secondary></indexterm>
616     <indexterm><primary><option>&ndash;&ndash;interactive</option></primary></indexterm>
617
618     <para>GHCi is invoked with the command <literal>ghci</literal> or
619     <literal>ghc &ndash;&ndash;interactive</literal>.  One or more modules or
620     filenames can also be specified on the command line; this
621     instructs GHCi to load the specified modules or filenames (and all
622     the modules they depend on), just as if you had said
623     <literal>:load <replaceable>modules</replaceable></literal> at the
624     GHCi prompt (see <xref linkend="ghci-commands">).  For example, to
625     start GHCi and load the program whose topmost module is in the
626     file <literal>Main.hs</literal>, we could say:</para>
627
628 <screen>
629 $ ghci Main.hs
630 </screen>
631
632     <para>Most of the command-line options accepted by GHC (see <xref
633     linkend="using-ghc">) also make sense in interactive mode.  The ones
634     that don't make sense are mostly obvious; for example, GHCi
635     doesn't generate interface files, so options related to interface
636     file generation won't have any effect.</para>
637
638     <sect2>
639       <title>Packages</title>
640       <indexterm><primary>packages</primary><secondary>with GHCi</secondary></indexterm>
641
642       <para>GHCi can make use of all the packages that come with GHC,
643       For example, to start up GHCi with the <literal>text</literal>
644       package loaded:</para>
645
646 <screen>
647 $ ghci -package text
648    ___         ___ _
649   / _ \ /\  /\/ __(_)
650  / /_\// /_/ / /  | |      GHC Interactive, version 5.00, For Haskell 98.
651 / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
652 \____/\/ /_/\____/|_|      Type :? for help.
653
654 Loading package std ... linking ... done.
655 Loading package lang ... linking ... done.
656 Loading package text ... linking ... done.
657 Prelude> 
658 </screen>      
659
660       <para>Note that GHCi also loaded the <literal>lang</literal>
661       package even though we didn't ask for it: that's because the
662       <literal>text</literal> package makes use of one or more of the
663       modules in <literal>lang</literal>, and therefore has a
664       dependency on it.</para>
665
666       <para>The following command works to load new packages into a
667       running GHCi:</para>
668
669 <screen>
670 Prelude> :set -package <replaceable>name</replaceable>
671 </screen>
672
673       <para>But note that doing this will cause all currently loaded
674       modules to be unloaded, and you'll be dumped back into the
675       Prelude.</para>
676     </sect2>
677
678     <sect2>
679       <title>Extra libraries</title>
680       <indexterm><primary>libraries</primary><secondary>with GHCi</secondary></indexterm>
681       
682       <para>Extra libraries may be specified on the command line using
683       the normal <literal>-l<replaceable>lib</replaceable></literal>
684       option.  For example, to load the &ldquo;m&rdquo; library:</para>
685
686 <screen>
687 $ ghci -lm
688 </screen>
689
690       <para>On systems with <literal>.so</literal>-style shared
691       libraries, the actual library loaded will the
692       <filename>lib<replaceable>lib</replaceable>.so</filename>.  GHCi
693       searches the following places for libraries, in this order:</para>
694
695       <itemizedlist>
696         <listitem>
697           <para>Paths specified using the
698           <literal>-L<replaceable>path</replaceable></literal>
699           command-line option,</para>
700         </listitem>
701         <listitem>
702           <para>the standard library search path for your system,
703           which on some systems may be overriden by setting the
704           <literal>LD_LIBRARY_PATH</literal> environment
705           variable.</para>
706         </listitem>
707       </itemizedlist>
708
709       <para>On systems with <literal>.dll</literal>-style shared
710       libraries, the actual library loaded will be
711       <filename><replaceable>lib</replaceable>.dll</filename>.  Again,
712       GHCi will signal an error if it can't find the library.</para>
713
714       <para>GHCi can also load plain object files
715       (<literal>.o</literal> or <literal>.obj</literal> depending on
716       your platform) from the command-line.  Just add the name the
717       object file to the command line.</para>
718     </sect2>
719
720   </sect1>
721
722   <sect1 id="ghci-commands">
723     <title>GHCi commands</title>
724
725     <para>GHCi commands all begin with
726     &lsquo;<literal>:</literal>&rsquo; and consist of a single command
727     name followed by zero or more parameters.  The command name may be
728     abbreviated, as long as the abbreviation is not ambiguous.  All of
729     the builtin commands, with the exception of
730     <literal>:unset</literal> and <literal>:undef</literal>, may be
731     abbreviated to a single letter.</para>
732
733     <variablelist>
734       <varlistentry>
735         <term><literal>:add</literal>
736         <replaceable>module</replaceable> ...</term>
737         <indexterm><primary><literal>:add</literal></primary></indexterm>
738         <listitem>
739           <para>Add <replaceable>module</replaceable>(s) to the
740           current <firstterm>target set</firstterm>, and perform a
741           reload.</para>
742         </listitem>
743       </varlistentry>
744
745       <varlistentry>
746         <term><literal>:browse</literal>
747         <optional><literal>*</literal></optional><replaceable>module</replaceable>
748         ...</term>
749         <indexterm><primary><literal>:browse</literal></primary>
750         </indexterm>
751         <listitem>
752           <para>Displays the identifiers defined by the module
753           <replaceable>module</replaceable>, which must be either
754           loaded into GHCi or be a member of a package.  If the
755           <literal>*</literal> symbol is placed before the module
756           name, then <emphasis>all</emphasis> the identifiers defined
757           in <replaceable>module</replaceable> are shown; otherwise
758           the list is limited to the exports of
759           <replaceable>module</replaceable>.  The
760           <literal>*</literal>-form is only available for modules
761           which are interpreted; for compiled modules (including
762           modules from packages) only the non-<literal>*</literal>
763           form of <literal>:browse</literal> is available.</para>
764         </listitem>
765       </varlistentry>
766
767       <varlistentry>
768         <term><literal>:cd</literal> <replaceable>dir</replaceable></term>
769         <indexterm><primary><literal>:cd</literal></primary></indexterm>
770         <listitem>
771           <para>Changes the current working directory to
772           <replaceable>dir</replaceable>.  A
773           &lsquo;<literal>&tilde;</literal>&rsquo; symbol at the
774           beginning of <replaceable>dir</replaceable> will be replaced
775           by the contents of the environment variable
776           <literal>HOME</literal>.</para>
777         </listitem>
778       </varlistentry>
779
780       <varlistentry>
781         <term><literal>:def</literal> <replaceable>name</replaceable> <replaceable>expr</replaceable></term>
782         <indexterm><primary><literal>:def</literal></primary></indexterm>
783         <listitem>
784           <para>The command <literal>:def</literal>
785           <replaceable>name</replaceable>
786           <replaceable>expr</replaceable> defines a new GHCi command
787           <literal>:<replaceable>name</replaceable></literal>,
788           implemented by the Haskell expression
789           <replaceable>expr</replaceable>, which must have type
790           <literal>String -> IO String</literal>.  When
791           <literal>:<replaceable>name</replaceable>
792           <replaceable>args</replaceable></literal> is typed at the
793           prompt, GHCi will run the expression
794           <literal>(<replaceable>name</replaceable>
795           <replaceable>args</replaceable>)</literal>, take the
796           resulting <literal>String</literal>, and feed it back into
797           GHCi as a new sequence of commands.  Separate commands in
798           the result must be separated by
799           &lsquo;<literal>\n</literal>&rsquo;.</para>
800
801           <para>That's all a little confusing, so here's a few
802           examples.  To start with, here's a new GHCi command which
803           doesn't take any arguments or produce any results, it just
804           outputs the current date & time:</para>
805
806 <screen>
807 Prelude> let date _ = Time.getClockTime >>= print >> return ""
808 Prelude> :def date date
809 Prelude> :date
810 Fri Mar 23 15:16:40 GMT 2001
811 </screen>
812
813           <para>Here's an example of a command that takes an argument.
814           It's a re-implementation of <literal>:cd</literal>:</para>
815
816 <screen>
817 Prelude> let mycd d = Directory.setCurrentDirectory d >> return ""
818 Prelude> :def mycd mycd
819 Prelude> :mycd ..
820 </screen>
821
822           <para>Or I could define a simple way to invoke
823           &ldquo;<literal>ghc &ndash;&ndash;make Main</literal>&rdquo; in the
824           current directory:</para>
825
826 <screen>
827 Prelude> :def make (\_ -> return ":! ghc &ndash;&ndash;make Main")
828 </screen>
829
830         </listitem>
831       </varlistentry>
832
833       <varlistentry>
834         <term><literal>:help</literal></term>
835         <indexterm><primary><literal>:help</literal></primary></indexterm>
836         <term><literal>:?</literal></term>
837         <indexterm><primary><literal>:?</literal></primary></indexterm>
838         <listitem>
839           <para>Displays a list of the available commands.</para>
840         </listitem>
841       </varlistentry>
842
843       <varlistentry>
844         <term><literal>:info</literal> <replaceable>name</replaceable>
845         ...</term>
846         <indexterm><primary><literal>:info</literal></primary>
847         </indexterm>
848         <listitem>
849           <para>Displays information about the given name(s).  For
850           example, if <replaceable>name</replaceable> is a class, then
851           the class methods and their types will be printed;  if
852           <replaceable>name</replaceable> is a type constructor, then
853           its definition will be printed;  if
854           <replaceable>name</replaceable> is a function, then its type
855           will be printed.  If <replaceable>name</replaceable> has
856           been loaded from a source file, then GHCi will also display
857           the location of its definition in the source.</para>
858         </listitem>
859       </varlistentry>
860
861       <varlistentry>
862         <term><literal>:load</literal>
863         <replaceable>module</replaceable> ...</term>
864         <indexterm><primary><literal>:load</literal></primary></indexterm>
865         <listitem>
866           <para>Recursively loads the specified
867           <replaceable>module</replaceable>s, and all the modules they
868           depend on.  Here, each <replaceable>module</replaceable>
869           must be a module name or filename, but may not be the name
870           of a module in a package.</para>
871
872           <para>All previously loaded modules, except package modules,
873           are forgotten.  The new set of modules is known as the
874           <firstterm>target set</firstterm>.</para>
875
876           <para>After a <literal>:load</literal> command, the current
877           context is set to:</para>
878
879           <itemizedlist>
880             <listitem>
881               <para><replaceable>module</replaceable>, if it was loaded
882               successfully, or</para>
883             </listitem>
884             <listitem>
885               <para>the most recently successfully loaded module, if
886               any other modules were loaded as a result of the current
887               <literal>:load</literal>, or</para>
888             </listitem>
889             <listitem>
890               <para><literal>Prelude</literal> otherwise.</para>
891             </listitem>
892           </itemizedlist>
893         </listitem>
894       </varlistentry>
895
896       <varlistentry>
897         <term><literal>:module <optional>+|-</optional> <optional>*</optional><replaceable>mod<subscript>1</subscript></replaceable> ... <optional>*</optional><replaceable>mod<subscript>n</subscript></replaceable></literal></term>
898         <indexterm><primary><literal>:module</literal></primary></indexterm>
899         <listitem>
900           <para>Sets or modifies the current context for statements
901           typed at the prompt.  See <xref linkend="ghci-scope"> for
902           more details.</para>
903         </listitem>
904       </varlistentry>
905
906       <varlistentry>
907         <term><literal>:quit</literal></term>
908         <indexterm><primary><literal>:quit</literal></primary></indexterm>
909         <listitem>
910           <para>Quits GHCi.  You can also quit by typing a control-D
911           at the prompt.</para>
912         </listitem>
913       </varlistentry>
914
915       <varlistentry>
916         <term><literal>:reload</literal></term>
917         <indexterm><primary><literal>:reload</literal></primary></indexterm>
918         <listitem>
919           <para>Attempts to reload the current target set (see
920           <literal>:load</literal>) if any of the modules in the set,
921           or any dependent module, has changed.  Note that this may
922           entail loading new modules, or dropping modules which are no
923           longer indirectly required by the target.</para>
924         </listitem>
925       </varlistentry>
926
927       <varlistentry>
928         <term><literal>:set</literal> <optional><replaceable>option</replaceable>...</optional></term>
929         <indexterm><primary><literal>:set</literal></primary></indexterm>
930         <listitem>
931           <para>Sets various options.  See <xref linkend="ghci-set">
932           for a list of available options.  The
933           <literal>:set</literal> command by itself shows which
934           options are currently set.</para>
935         </listitem>
936       </varlistentry>
937
938       <varlistentry>
939         <term><literal>:set</literal> <literal>args</literal>
940         <replaceable>arg</replaceable> ...</term>
941         <indexterm><primary><literal>:set</literal></primary></indexterm>
942         <listitem>
943           <para>Sets the list of arguments which are returned when the
944           program calls <literal>System.getArgs</literal><indexterm><primary>getArgs</primary>
945             </indexterm>.</para>
946         </listitem>
947       </varlistentry>
948
949       <varlistentry>
950         <term><literal>:set</literal> <literal>prog</literal>
951         <replaceable>prog</replaceable></term>
952         <indexterm><primary><literal>:set</literal></primary></indexterm>
953         <listitem>
954           <para>Sets the string to be returned when the program calls
955           <literal>System.getProgName</literal><indexterm><primary>getProgName</primary>
956             </indexterm>.</para>
957         </listitem>
958       </varlistentry>
959
960       <varlistentry>
961         <term><literal>:show bindings</literal></term>
962         <indexterm><primary><literal>:show bindings</literal></primary></indexterm>
963         <listitem>
964           <para>Show the bindings made at the prompt and their
965           types.</para>
966         </listitem>
967       </varlistentry>
968
969       <varlistentry>
970         <term><literal>:show modules</literal></term>
971         <indexterm><primary><literal>:show modules</literal></primary></indexterm>
972         <listitem>
973           <para>Show the list of modules currently load.</para>
974         </listitem>
975       </varlistentry>
976
977       <varlistentry>
978         <term><literal>:type</literal> <replaceable>expression</replaceable></term>
979         <indexterm><primary><literal>:type</literal></primary></indexterm>
980         <listitem>
981           <para>Infers and prints the type of
982           <replaceable>expression</replaceable>, including explicit
983           forall quantifiers for polymorphic types.  The monomorphism
984           restriction is <emphasis>not</emphasis> applied to the
985           expression during type inference.</para>
986         </listitem>
987       </varlistentry>
988
989       <varlistentry>
990         <term><literal>:undef</literal> <replaceable>name</replaceable></term>
991         <indexterm><primary><literal>:undef</literal></primary></indexterm>
992         <listitem>
993           <para>Undefines the user-defined command
994           <replaceable>name</replaceable> (see <literal>:def</literal>
995           above).</para>
996         </listitem>
997       </varlistentry>
998
999       <varlistentry>
1000         <term><literal>:unset</literal> <replaceable>option</replaceable>...</term>
1001         <indexterm><primary><literal>:unset</literal></primary></indexterm>
1002         <listitem>
1003           <para>Unsets certain options.  See <xref linkend="ghci-set">
1004           for a list of available options.</para>
1005         </listitem>
1006       </varlistentry>
1007
1008       <varlistentry>
1009         <term><literal>:!</literal> <replaceable>command</replaceable>...</term>
1010         <indexterm><primary><literal>:!</literal></primary></indexterm>
1011         <indexterm><primary>shell commands</primary><secondary>in GHCi</secondary></indexterm>
1012         <listitem>
1013           <para>Executes the shell command
1014           <replaceable>command</replaceable>.</para>
1015         </listitem>
1016       </varlistentry>
1017
1018     </variablelist>
1019   </sect1>
1020
1021   <sect1 id="ghci-set">
1022     <title>The <literal>:set</literal> command</title>
1023     <indexterm><primary><literal>:set</literal></primary></indexterm>
1024
1025     <para>The <literal>:set</literal> command sets two types of
1026     options: GHCi options, which begin with
1027     &lsquo;<literal>+</literal>&rdquo; and &ldquo;command-line&rdquo;
1028     options, which begin with &lsquo;-&rsquo;.  </para>
1029
1030     <sect2>
1031       <title>GHCi options</title>
1032       <indexterm><primary>options</primary><secondary>GHCi</secondary>
1033       </indexterm>
1034
1035       <para>GHCi options may be set using <literal>:set</literal> and
1036       unset using <literal>:unset</literal>.</para>
1037
1038       <para>The available GHCi options are:</para>
1039
1040       <variablelist>
1041         <varlistentry>
1042           <term><literal>+r</literal></term>
1043           <indexterm><primary><literal>+r</literal></primary></indexterm>
1044           <indexterm><primary>CAFs</primary><secondary>in GHCi</secondary></indexterm>
1045           <indexterm><primary>Constant Applicative Form</primary><see>CAFs</see></indexterm>
1046           <listitem>
1047             <para>Normally, any evaluation of top-level expressions
1048             (otherwise known as CAFs or Constant Applicative Forms) in
1049             loaded modules is retained between evaluations.  Turning
1050             on <literal>+r</literal> causes all evaluation of
1051             top-level expressions to be discarded after each
1052             evaluation (they are still retained
1053             <emphasis>during</emphasis> a single evaluation).</para>
1054           
1055             <para>This option may help if the evaluated top-level
1056             expressions are consuming large amounts of space, or if
1057             you need repeatable performance measurements.</para>
1058           </listitem>
1059         </varlistentry>
1060
1061         <varlistentry>
1062           <term><literal>+s</literal></term>
1063           <indexterm><primary><literal>+s</literal></primary></indexterm>
1064           <listitem>
1065             <para>Display some stats after evaluating each expression,
1066             including the elapsed time and number of bytes allocated.
1067             NOTE: the allocation figure is only accurate to the size
1068             of the storage manager's allocation area, because it is
1069             calculated at every GC.  Hence, you might see values of
1070             zero if no GC has occurred.</para>
1071           </listitem>
1072         </varlistentry>
1073
1074         <varlistentry>
1075           <term><literal>+t</literal></term>
1076           <indexterm><primary><literal>+t</literal></primary></indexterm>
1077           <listitem>
1078             <para>Display the type of each variable bound after a
1079             statement is entered at the prompt.  If the statement is a
1080             single expression, then the only variable binding will be
1081             for the variable
1082             &lsquo;<literal>it</literal>&rsquo;.</para>
1083           </listitem>
1084         </varlistentry>
1085       </variablelist>
1086     </sect2>
1087
1088     <sect2 id="ghci-cmd-line-options">
1089       <title>Setting GHC command-line options in GHCi</title>
1090
1091       <para>Normal GHC command-line options may also be set using
1092       <literal>:set</literal>.  For example, to turn on
1093       <option>-fglasgow-exts</option>, you would say:</para>
1094
1095 <screen>
1096 Prelude> :set -fglasgow-exts
1097 </screen>
1098       
1099       <para>Any GHC command-line option that is designated as
1100       <firstterm>dynamic</firstterm> (see the table in <xref
1101       linkend="flag-reference">), may be set using
1102       <literal>:set</literal>.  To unset an option, you can set the
1103       reverse option:</para>
1104       <indexterm><primary>dynamic</primary><secondary>options</secondary></indexterm>
1105
1106 <screen>
1107 Prelude> :set -fno-glasgow-exts
1108 </screen>
1109
1110       <para><xref linkend="flag-reference"> lists the reverse for each
1111       option where applicable.</para>
1112
1113       <para>Certain static options (<option>-package</option>,
1114       <option>-I</option>, <option>-i</option>, and
1115       <option>-l</option> in particular) will also work, but some may
1116       not take effect until the next reload.</para>
1117       <indexterm><primary>static</primary><secondary>options</secondary></indexterm>
1118     </sect2>
1119   </sect1>
1120
1121   <sect1 id="ghci-dot-files">
1122     <title>The <filename>.ghci</filename> file</title>
1123     <indexterm><primary><filename>.ghci</filename></primary><secondary>file</secondary>
1124     </indexterm>
1125     <indexterm><primary>startup</primary><secondary>files, GHCi</secondary>
1126     </indexterm>
1127
1128     <para>When it starts, GHCi always reads and executes commands from
1129     <filename>$HOME/.ghci</filename>, followed by
1130     <filename>./.ghci</filename>.</para>
1131
1132     <para>The <filename>.ghci</filename> in your home directory is
1133     most useful for turning on favourite options (eg. <literal>:set
1134     +s</literal>), and defining useful macros.  Placing a
1135     <filename>.ghci</filename> file in a directory with a Haskell
1136     project is a useful way to set certain project-wide options so you
1137     don't have to type them everytime you start GHCi: eg. if your
1138     project uses GHC extensions and CPP, and has source files in three
1139     subdirectories A B and C, you might put the following lines in
1140     <filename>.ghci</filename>:</para>
1141
1142 <screen>
1143 :set -fglasgow-exts -cpp
1144 :set -iA:B:C
1145 </screen>
1146
1147     <para>(Note that strictly speaking the <option>-i</option> flag is
1148     a static one, but in fact it works to set it using
1149     <literal>:set</literal> like this.  The changes won't take effect
1150     until the next <literal>:load</literal>, though.)</para>
1151
1152     <para>Two command-line options control whether the
1153     <filename>.ghci</filename> files are read:</para>
1154
1155     <variablelist>
1156       <varlistentry>
1157         <term><option>-ignore-dot-ghci</option></term>
1158         <indexterm><primary><option>-ignore-dot-ghci</option></primary>
1159         </indexterm>
1160         <listitem>
1161           <para>Don't read either <filename>./.ghci</filename> or
1162           <filename>$HOME/.ghci</filename> when starting up.</para>
1163         </listitem>
1164       </varlistentry>
1165       <varlistentry>
1166         <term><option>-read-dot-ghci</option></term>
1167         <indexterm><primary><option>-read-dot-ghci</option></primary>
1168         </indexterm>
1169         <listitem>
1170           <para>Read <filename>.ghci</filename> and
1171           <filename>$HOME/.ghci</filename>.  This is normally the
1172           default, but the <option>-read-dot-ghci</option> option may
1173           be used to override a previous
1174           <option>-ignore-dot-ghci</option> option.</para>
1175         </listitem>
1176       </varlistentry>
1177     </variablelist>
1178
1179   </sect1>
1180
1181   <sect1>
1182     <title>FAQ and Things To Watch Out For</title>
1183     
1184     <variablelist>
1185       <varlistentry>
1186         <term>GHCi complains about <function>main</function> not being
1187         in scope when I load a module.</term>
1188         <indexterm><primary><function>main</function></primary><secondary>with GHCi</secondary>
1189         </indexterm>
1190         <listitem>
1191           <para>You probably omitted the <literal>module</literal>
1192           declaration at the top of the module, which causes the
1193           module name to default to <literal>Main</literal>.  In
1194           Haskell, the <literal>Main</literal> module must define a
1195           function called <function>main</function>.  Admittedly this
1196           doesn't make a great deal of sense for an interpreter, but
1197           the rule was kept for compatibility with GHC.</para>
1198         </listitem>
1199       </varlistentry>
1200
1201       <varlistentry>
1202         <term>The interpreter can't load modules with foreign export
1203         declarations!</term>
1204         <listitem>
1205           <para>Unfortunately not.  We haven't implemented it yet.
1206           Please compile any offending modules by hand before loading
1207           them into GHCi.</para>
1208         </listitem>
1209       </varlistentry>
1210
1211       <varlistentry>
1212         <term><literal>-O</literal> doesn't work with GHCi!</term>
1213         <indexterm><primary><option>-O</option></primary>
1214         </indexterm>
1215         <listitem>
1216           <para>For technical reasons, the bytecode compiler doesn't
1217           interact well with one of the optimisation passes, so we
1218           have disabled optimisation when using the interpreter.  This
1219           isn't a great loss: you'll get a much bigger win by
1220           compiling the bits of your code that need to go fast, rather
1221           than interpreting them with optimisation turned on.</para>
1222         </listitem>
1223       </varlistentry>
1224
1225       <varlistentry>
1226         <term>Unboxed tuples don't work with GHCi</term>
1227         <listitem>
1228           <para>That's right.  You can always compile a module that
1229           uses unboxed tuples and load it into GHCi, however.
1230           (Incidentally the previous point, namely that
1231           <literal>-O</literal> is incompatible with GHCi, is because
1232           the bytecode compiler can't deal with unboxed
1233           tuples).</para>
1234         </listitem>
1235       </varlistentry>
1236
1237       <varlistentry>
1238         <term>Concurrent threads don't carry on running when GHCi is
1239         waiting for input.</term>
1240         <listitem>
1241           <para>No, they don't.  This is because the Haskell binding
1242           to the GNU readline library doesn't support reading from the
1243           terminal in a non-blocking way, which is required to work
1244           properly with GHC's concurrency model.</para>
1245         </listitem>
1246       </varlistentry>
1247
1248       <varlistentry>
1249         <term>After using <literal>getContents</literal>, I can't use
1250         <literal>stdin</literal> again until I do
1251         <literal>:load</literal> or <literal>:reload</literal>.</term>
1252
1253         <listitem>
1254           <para>This is the defined behaviour of
1255           <literal>getContents</literal>: it puts the stdin Handle in
1256           a state known as <firstterm>semi-closed</firstterm>, wherein
1257           any further I/O operations on it are forbidden.  Because I/O
1258           state is retained between computations, the semi-closed
1259           state persists until the next <literal>:load</literal> or
1260           <literal>:reload</literal> command.</para>
1261
1262           <para>You can make <literal>stdin</literal> reset itself
1263           after every evaluation by giving GHCi the command
1264           <literal>:set +r</literal>.  This works because
1265           <literal>stdin</literal> is just a top-level expression that
1266           can be reverted to its unevaluated state in the same way as
1267           any other top-level expression (CAF).</para>
1268         </listitem>
1269       </varlistentry>
1270
1271     </variablelist>
1272   </sect1>
1273
1274 </chapter>
1275
1276 <!-- Emacs stuff:
1277      ;;; Local Variables: ***
1278      ;;; mode: sgml ***
1279      ;;; sgml-parent-document: ("users_guide.sgml" "book" "chapter") ***
1280      ;;; End: ***
1281  -->