59723d735d71b8e526a03d62ab9b753815645976
[ghc-hetmet.git] / docs / users_guide / separate_compilation.xml
1 <?xml version="1.0" encoding="iso-8859-1"?>
2   <sect1 id="separate-compilation">
3     <title>Filenames and separate compilation</title>
4
5     <indexterm><primary>separate compilation</primary></indexterm>
6     <indexterm><primary>recompilation checker</primary></indexterm>
7     <indexterm><primary>make and recompilation</primary></indexterm>
8
9     <para>This section describes what files GHC expects to find, what
10     files it creates, where these files are stored, and what options
11     affect this behaviour.</para>
12
13     <para>Note that this section is written with
14     <firstterm>hierarchical modules</firstterm> in mind (see <xref
15     linkend="hierarchical-modules"/>); hierarchical modules are an
16     extension to Haskell 98 which extends the lexical syntax of
17     module names to include a dot &lsquo;.&rsquo;.  Non-hierarchical
18     modules are thus a special case in which none of the module names
19     contain dots.</para>
20
21     <para>Pathname conventions vary from system to system.  In
22     particular, the directory separator is
23     &lsquo;<literal>/</literal>&rsquo; on Unix systems and
24     &lsquo;<literal>\</literal>&rsquo; on Windows systems.  In the
25     sections that follow, we shall consistently use
26     &lsquo;<literal>/</literal>&rsquo; as the directory separator;
27     substitute this for the appropriate character for your
28     system.</para>
29
30     <sect2 id="source-files">
31       <title>Haskell source files</title>
32
33       <indexterm><primary>filenames</primary></indexterm>
34
35       <para>Each Haskell source module should be placed in a file on
36       its own.</para>
37
38       <para>Usually, the file should be named after the module name,
39       replacing dots in the module name by directory separators.  For
40       example, on a Unix system, the module <literal>A.B.C</literal>
41       should be placed in the file <literal>A/B/C.hs</literal>,
42       relative to some base directory.  If the module is not going to
43       be imported by another module (<literal>Main</literal>, for
44       example), then you are free to use any filename for it.</para>
45
46       <indexterm><primary>unicode</primary></indexterm>
47
48       <para> GHC assumes that source files are
49       ASCII<indexterm><primary>ASCII</primary></indexterm> or
50       UTF-8<indexterm><primary>UTF-8</primary></indexterm> only, other
51       encodings<indexterm><primary>encoding</primary></indexterm> are
52       not recognised.  However, invalid UTF-8 sequences will be
53       ignored in comments, so it is possible to use other encodings
54       such as
55       Latin-1<indexterm><primary>Latin-1</primary></indexterm>, as
56       long as the non-comment source code is ASCII only.</para>
57     </sect2>
58
59     <sect2 id="output-files">
60       <title>Output files</title>
61
62       <indexterm><primary>interface files</primary></indexterm>
63       <indexterm><primary><literal>.hi</literal> files</primary></indexterm>
64       <indexterm><primary>object files</primary></indexterm>
65       <indexterm><primary><literal>.o</literal> files</primary></indexterm>
66
67       <para>When asked to compile a source file, GHC normally
68       generates two files: an <firstterm>object file</firstterm>, and
69       an <firstterm>interface file</firstterm>. </para>
70
71       <para>The object file, which normally ends in a
72       <literal>.o</literal> suffix, contains the compiled code for the
73       module.</para>
74
75       <para>The interface file,
76       which normally ends in a <literal>.hi</literal> suffix, contains
77       the information that GHC needs in order to compile further
78       modules that depend on this module.  It contains things like the
79       types of exported functions, definitions of data types, and so
80       on.  It is stored in a binary format, so don't try to read one;
81       use the <option>--show-iface</option> option instead (see <xref
82       linkend="hi-options"/>).</para>
83
84       <para>You should think of the object file and the interface file as a
85       pair, since the interface file is in a sense a compiler-readable
86       description of the contents of the object file.  If the
87       interface file and object file get out of sync for any reason,
88       then the compiler may end up making assumptions about the object
89       file that aren't true; trouble will almost certainly follow.
90       For this reason, we recommend keeping object files and interface
91       files in the same place (GHC does this by default, but it is
92       possible to override the defaults as we'll explain
93       shortly).</para>
94
95       <para>Every module has a <emphasis>module name</emphasis>
96       defined in its source code (<literal>module A.B.C where
97       ...</literal>).</para>
98
99       <para>The name of the object file generated by GHC is derived
100       according to the following rules, where
101       <replaceable>osuf</replaceable> is the object-file suffix (this
102       can be changed with the <option>-osuf</option> option).</para>
103
104       <itemizedlist>
105         <listitem>
106           <para>If there is no <option>-odir</option> option (the
107           default), then the object filename is derived from the
108           source filename (ignoring the module name) by replacing the
109           suffix with <replaceable>osuf</replaceable>.</para>
110         </listitem>
111         <listitem>
112           <para>If
113           <option>-odir</option>&nbsp;<replaceable>dir</replaceable>
114           has been specified, then the object filename is
115           <replaceable>dir</replaceable>/<replaceable>mod</replaceable>.<replaceable>osuf</replaceable>,
116           where <replaceable>mod</replaceable> is the module name with
117           dots replaced by slashes.  GHC will silently create the necessary directory 
118           structure underneath <replaceable>dir</replaceable>, if it does not
119           already exist.</para> 
120         </listitem>
121       </itemizedlist>
122
123       <para>The name of the interface file is derived using the same
124       rules, except that the suffix is
125       <replaceable>hisuf</replaceable> (<literal>.hi</literal> by
126       default) instead of <replaceable>osuf</replaceable>, and the
127       relevant options are <option>-hidir</option> and
128       <option>-hisuf</option> instead of <option>-odir</option> and
129       <option>-osuf</option> respectively.</para>
130
131       <para>For example, if GHC compiles the module
132       <literal>A.B.C</literal> in the file
133       <filename>src/A/B/C.hs</filename>, with no
134       <literal>-odir</literal> or <literal>-hidir</literal> flags, the
135       interface file will be put in <literal>src/A/B/C.hi</literal>
136       and the object file in <literal>src/A/B/C.o</literal>.</para>
137
138       <para>For any module that is imported, GHC requires that the
139       name of the module in the import statement exactly matches the
140       name of the module in the interface file (or source file) found
141       using the strategy specified in <xref linkend="search-path"/>.
142       This means that for most modules, the source file name should
143       match the module name.</para>
144
145       <para>However, note that it is reasonable to have a module
146       <literal>Main</literal> in a file named
147       <filename>foo.hs</filename>, but this only works because GHC
148       never needs to search for the interface for module
149       <literal>Main</literal> (because it is never imported).  It is
150       therefore possible to have several <literal>Main</literal>
151       modules in separate source files in the same directory, and GHC
152       will not get confused.</para>
153
154       <para>In batch compilation mode, the name of the object file can
155       also be overridden using the <option>-o</option> option, and the
156       name of the interface file can be specified directly using the
157       <option>-ohi</option> option.</para>
158     </sect2>
159
160     <sect2 id="search-path">
161       <title>The search path</title>
162
163       <indexterm><primary>search path</primary>
164       </indexterm>
165       <indexterm><primary>interface files, finding them</primary></indexterm>
166       <indexterm><primary>finding interface files</primary></indexterm>
167
168       <para>In your program, you import a module
169       <literal>Foo</literal> by saying <literal>import Foo</literal>.
170       In <option>--make</option> mode or GHCi, GHC will look for a
171       source file for <literal>Foo</literal> and arrange to compile it
172       first.  Without <option>--make</option>, GHC will look for the
173       interface file for <literal>Foo</literal>, which should have
174       been created by an earlier compilation of
175       <literal>Foo</literal>.  GHC uses the same strategy in each of
176       these cases for finding the appropriate file.</para>
177
178       <para>This strategy is as follows: GHC keeps a list of
179       directories called the <firstterm>search path</firstterm>.  For
180       each of these directories, it tries appending
181       <replaceable>basename</replaceable><literal>.</literal><replaceable>extension</replaceable>
182       to the directory, and checks whether the file exists.  The value
183       of <replaceable>basename</replaceable> is the module name with
184       dots replaced by the directory separator ('/' or '\', depending
185       on the system), and <replaceable>extension</replaceable> is a
186       source extension (<literal>hs</literal>, <literal>lhs</literal>)
187       if we are in <option>--make</option> mode and GHCi, or
188       <replaceable>hisuf</replaceable> otherwise.</para>
189
190       <para>For example, suppose the search path contains directories
191       <literal>d1</literal>, <literal>d2</literal>, and
192       <literal>d3</literal>, and we are in <literal>--make</literal>
193       mode looking for the source file for a module
194       <literal>A.B.C</literal>.  GHC will look in
195       <literal>d1/A/B/C.hs</literal>, <literal>d1/A/B/C.lhs</literal>,
196       <literal>d2/A/B/C.hs</literal>, and so on.</para>
197
198       <para>The search path by default contains a single directory:
199       <quote>.</quote> (i.e. the current directory).  The following
200       options can be used to add to or change the contents of the
201       search path:</para>
202
203       <variablelist>
204         <varlistentry>
205           <term><option>-i<replaceable>dirs</replaceable></option></term>
206           <listitem>
207             <para><indexterm><primary><option>-i<replaceable>dirs</replaceable></option>
208             </primary></indexterm>This flag appends a colon-separated
209             list of <filename>dirs</filename> to the search path.</para>
210           </listitem>
211         </varlistentry>
212
213         <varlistentry>
214           <term><option>-i</option></term>
215           <listitem>
216             <para>resets the search path back to nothing.</para>
217           </listitem>
218         </varlistentry>
219       </variablelist>
220
221       <para>This isn't the whole story: GHC also looks for modules in
222       pre-compiled libraries, known as packages.  See the section on
223       packages (<xref linkend="packages"/>), for details.</para>
224     </sect2>
225
226     <sect2 id="options-output">
227       <title>Redirecting the compilation output(s)</title>
228
229       <indexterm><primary>output-directing options</primary></indexterm>
230       <indexterm><primary>redirecting compilation output</primary></indexterm>
231
232       <variablelist>
233         <varlistentry>
234           <term>
235             <option>-o</option> <replaceable>file</replaceable>
236             <indexterm><primary><option>-o</option></primary></indexterm>
237           </term>
238           <listitem>
239             <para>GHC's compiled output normally goes into a
240             <filename>.hc</filename>, <filename>.o</filename>, etc.,
241             file, depending on the last-run compilation phase.  The
242             option <option>-o <replaceable>file</replaceable></option>
243             re-directs the output of that last-run phase to
244             <replaceable>file</replaceable>.</para>
245
246             <para>Note: this &ldquo;feature&rdquo; can be
247             counterintuitive: <command>ghc -C -o foo.o
248             foo.hs</command> will put the intermediate C code in the
249             file <filename>foo.o</filename>, name
250             notwithstanding!</para>
251
252             <para>This option is most often used when creating an
253             executable file, to set the filename of the executable.
254             For example:
255 <screen>   ghc -o prog --make Main</screen>
256
257             will compile the program starting with module
258             <literal>Main</literal>  and put the executable in the
259             file <literal>prog</literal>.</para>
260
261             <para>Note: on Windows, if the result is an executable
262             file, the extension "<filename>.exe</filename>" is added
263             if the specified filename does not already have an
264             extension.  Thus
265 <programlisting>
266    ghc -o foo Main.hs
267 </programlisting>
268           will compile and link the module
269           <filename>Main.hs</filename>, and put the resulting
270           executable in <filename>foo.exe</filename> (not
271           <filename>foo</filename>).</para>
272
273           <para>If you use <command>ghc --make</command> and you don't
274           use the <option>-o</option>, the name GHC will choose
275           for the executable will be based on the name of the file
276           containing the module <literal>Main</literal>. 
277           Note that with GHC the <literal>Main</literal> module doesn't
278           have to be put in file <filename>Main.hs</filename>.
279           Thus both
280 <programlisting>
281    ghc --make Prog
282 </programlisting>
283           and
284 <programlisting>
285    ghc --make Prog.hs
286 </programlisting>
287           will produce <filename>Prog</filename> (or
288           <filename>Prog.exe</filename> if you are on Windows).</para>
289           </listitem>
290         </varlistentry>
291
292         <varlistentry>
293           <term>
294             <option>-odir</option> <replaceable>dir</replaceable>
295             <indexterm><primary><option>-odir</option></primary></indexterm>
296           </term>
297           <listitem>
298             <para>Redirects object files to directory
299             <replaceable>dir</replaceable>.  For example:</para>
300
301 <screen>
302 $ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch`
303 </screen>
304
305             <para>The object files, <filename>Foo.o</filename>,
306             <filename>Bar.o</filename>, and
307             <filename>Bumble.o</filename> would be put into a
308             subdirectory named after the architecture of the executing
309             machine (<filename>x86</filename>,
310             <filename>mips</filename>, etc).</para>
311
312             <para>Note that the <option>-odir</option> option does
313             <emphasis>not</emphasis> affect where the interface files
314             are put; use the <option>-hidir</option> option for that.
315             In the above example, they would still be put in
316             <filename>parse/Foo.hi</filename>,
317             <filename>parse/Bar.hi</filename>, and
318             <filename>gurgle/Bumble.hi</filename>.</para>
319           </listitem>
320         </varlistentry>
321
322         <varlistentry>
323           <term>
324             <option>-ohi</option>  <replaceable>file</replaceable>
325             <indexterm><primary><option>-ohi</option></primary></indexterm>
326           </term>
327           <listitem>
328             <para>The interface output may be directed to another file
329             <filename>bar2/Wurble.iface</filename> with the option
330             <option>-ohi bar2/Wurble.iface</option> (not
331             recommended).</para>
332
333             <para>WARNING: if you redirect the interface file
334             somewhere that GHC can't find it, then the recompilation
335             checker may get confused (at the least, you won't get any
336             recompilation avoidance).  We recommend using a
337             combination of <option>-hidir</option> and
338             <option>-hisuf</option> options instead, if
339             possible.</para>
340
341             <para>To avoid generating an interface at all, you could
342             use this option to redirect the interface into the bit
343             bucket: <literal>-ohi /dev/null</literal>, for
344             example.</para>
345           </listitem>
346         </varlistentry>
347
348         <varlistentry>
349           <term>
350             <option>-hidir</option>  <replaceable>dir</replaceable>
351             <indexterm><primary><option>-hidir</option></primary></indexterm>
352           </term>
353           <listitem>
354             <para>Redirects all generated interface files into
355             <replaceable>dir</replaceable>, instead of the
356             default.</para>
357           </listitem>
358         </varlistentry>
359
360         <varlistentry>
361           <term>
362             <option>-stubdir</option>  <replaceable>dir</replaceable>
363             <indexterm><primary><option>-stubdir</option></primary></indexterm>
364           </term>
365           <listitem>
366             <para>Redirects all generated FFI stub files into
367             <replaceable>dir</replaceable>.  Stub files are generated when the
368             Haskell source contains a <literal>foreign export</literal> or
369             <literal>foreign import "&amp;wrapper"</literal> declaration (see <xref
370               linkend="foreign-export-ghc" />).  The <option>-stubdir</option>
371               option behaves in exactly the same way as <option>-odir</option>
372               and <option>-hidir</option> with respect to hierarchical
373             modules.</para>
374           </listitem>
375         </varlistentry>
376
377         <varlistentry>
378           <term>
379             <option>-osuf</option> <replaceable>suffix</replaceable>
380             <indexterm><primary><option>-osuf</option></primary></indexterm>
381           </term>
382           <term>
383             <option>-hisuf</option> <replaceable>suffix</replaceable>
384             <indexterm><primary><option>-hisuf</option></primary></indexterm>
385           </term>
386           <term>
387             <option>-hcsuf</option> <replaceable>suffix</replaceable>
388             <indexterm><primary><option>-hcsuf</option></primary></indexterm>
389           </term>
390           <listitem>
391             <para>The <option>-osuf</option>
392             <replaceable>suffix</replaceable> will change the
393             <literal>.o</literal> file suffix for object files to
394             whatever you specify.  We use this when compiling
395             libraries, so that objects for the profiling versions of
396             the libraries don't clobber the normal ones.</para>
397
398             <para>Similarly, the <option>-hisuf</option>
399             <replaceable>suffix</replaceable> will change the
400             <literal>.hi</literal> file suffix for non-system
401             interface files (see <xref linkend="hi-options"/>).</para>
402
403             <para>Finally, the option <option>-hcsuf</option>
404             <replaceable>suffix</replaceable> will change the
405             <literal>.hc</literal> file suffix for compiler-generated
406             intermediate C files.</para>
407
408             <para>The <option>-hisuf</option>/<option>-osuf</option>
409             game is particularly useful if you want to compile a
410             program both with and without profiling, in the same
411             directory.  You can say:
412             <screen>
413               ghc ...</screen>
414             to get the ordinary version, and
415             <screen>
416               ghc ... -osuf prof.o -hisuf prof.hi -prof -auto-all</screen>
417             to get the profiled version.</para>
418           </listitem>
419         </varlistentry>
420       </variablelist>
421     </sect2>
422   
423     <sect2 id="keeping-intermediates">
424       <title>Keeping Intermediate Files</title>
425       <indexterm><primary>intermediate files, saving</primary>
426       </indexterm>
427       <indexterm><primary><literal>.hc</literal> files, saving</primary>
428       </indexterm>
429       <indexterm><primary><literal>.s</literal> files, saving</primary>
430       </indexterm>
431
432       <para>The following options are useful for keeping certain
433       intermediate files around, when normally GHC would throw these
434       away after compilation:</para>
435
436       <variablelist>
437         <varlistentry>
438           <term>
439             <option>-keep-hc-file</option>,
440             <option>-keep-hc-files</option>
441             <indexterm><primary><option>-keep-hc-file</option></primary></indexterm>
442             <indexterm><primary><option>-keep-hc-files</option></primary></indexterm>
443           </term>
444           <listitem>
445             <para>Keep intermediate <literal>.hc</literal> files when
446             doing <literal>.hs</literal>-to-<literal>.o</literal>
447             compilations via C (NOTE: <literal>.hc</literal> files
448             aren't generated when using the native code generator, you
449             may need to use <option>-fvia-C</option> to force them
450             to be produced).</para>
451           </listitem>
452         </varlistentry>
453
454         <varlistentry>
455           <term>
456             <option>-keep-s-file</option>,
457             <option>-keep-s-files</option>
458             <indexterm><primary><option>-keep-s-file</option></primary></indexterm>
459             <indexterm><primary><option>-keep-s-files</option></primary></indexterm>
460           </term>
461           <listitem>
462             <para>Keep intermediate <literal>.s</literal> files.</para>
463           </listitem>
464         </varlistentry>
465
466         <varlistentry>
467           <term>
468             <option>-keep-raw-s-file</option>,
469             <option>-keep-raw-s-files</option>
470             <indexterm><primary><option>-keep-raw-s-file</option></primary></indexterm>
471             <indexterm><primary><option>-keep-raw-s-files</option></primary></indexterm>
472           </term>
473           <listitem>
474             <para>Keep intermediate <literal>.raw-s</literal> files.
475             These are the direct output from the C compiler, before
476             GHC does &ldquo;assembly mangling&rdquo; to produce the
477             <literal>.s</literal> file.  Again, these are not produced
478             when using the native code generator.</para>
479           </listitem>
480         </varlistentry>
481
482         <varlistentry>
483           <term>
484             <option>-keep-tmp-files</option>
485             <indexterm><primary><option>-keep-tmp-files</option></primary></indexterm>
486             <indexterm><primary>temporary files</primary><secondary>keeping</secondary></indexterm>
487           </term>
488           <listitem>
489             <para>Instructs the GHC driver not to delete any of its
490             temporary files, which it normally keeps in
491             <literal>/tmp</literal> (or possibly elsewhere; see <xref
492             linkend="temp-files"/>).  Running GHC with
493             <option>-v</option> will show you what temporary files
494             were generated along the way.</para>
495           </listitem>
496         </varlistentry>
497       </variablelist>
498     </sect2>
499
500     <sect2 id="temp-files">
501       <title>Redirecting temporary files</title>
502
503       <indexterm>
504         <primary>temporary files</primary>
505         <secondary>redirecting</secondary>
506       </indexterm>
507
508       <variablelist>
509         <varlistentry>
510           <term>
511             <option>-tmpdir</option>
512             <indexterm><primary><option>-tmpdir</option></primary></indexterm>
513           </term>
514           <listitem>
515             <para>If you have trouble because of running out of space
516             in <filename>/tmp</filename> (or wherever your
517             installation thinks temporary files should go), you may
518             use the <option>-tmpdir
519             &lt;dir&gt;</option><indexterm><primary>-tmpdir
520             &lt;dir&gt; option</primary></indexterm> option to specify
521             an alternate directory.  For example, <option>-tmpdir
522             .</option> says to put temporary files in the current
523             working directory.</para>
524
525             <para>Alternatively, use your <constant>TMPDIR</constant>
526             environment variable.<indexterm><primary>TMPDIR
527             environment variable</primary></indexterm> Set it to the
528             name of the directory where temporary files should be put.
529             GCC and other programs will honour the
530             <constant>TMPDIR</constant> variable as well.</para>
531
532             <para>Even better idea: Set the
533             <constant>DEFAULT_TMPDIR</constant> make variable when
534             building GHC, and never worry about
535             <constant>TMPDIR</constant> again. (see the build
536             documentation).</para>
537           </listitem>
538         </varlistentry>
539       </variablelist>
540     </sect2>
541
542     <sect2 id="hi-options">
543       <title>Other options related to interface files</title>
544       <indexterm><primary>interface files, options</primary></indexterm>
545
546       <variablelist>
547         <varlistentry>
548           <term>
549             <option>-ddump-hi</option>
550             <indexterm><primary><option>-ddump-hi</option></primary></indexterm>
551           </term>
552           <listitem>
553             <para>Dumps the new interface to standard output.</para>
554           </listitem>
555         </varlistentry>
556
557         <varlistentry>
558           <term>
559             <option>-ddump-hi-diffs</option>
560             <indexterm><primary><option>-ddump-hi-diffs</option></primary></indexterm>
561           </term>
562           <listitem>
563             <para>The compiler does not overwrite an existing
564             <filename>.hi</filename> interface file if the new one is
565             the same as the old one; this is friendly to
566             <command>make</command>.  When an interface does change,
567             it is often enlightening to be informed.  The
568             <option>-ddump-hi-diffs</option> option will make GHC run
569             <command>diff</command> on the old and new
570             <filename>.hi</filename> files.</para>
571           </listitem>
572         </varlistentry>
573
574         <varlistentry>
575           <term>
576             <option>-ddump-minimal-imports</option>
577             <indexterm><primary><option>-ddump-minimal-imports</option></primary></indexterm>
578           </term>
579           <listitem>
580             <para>Dump to the file "M.imports" (where M is the module
581             being compiled) a "minimal" set of import declarations.
582             You can safely replace all the import declarations in
583             "M.hs" with those found in "M.imports".  Why would you
584             want to do that?  Because the "minimal" imports (a) import
585             everything explicitly, by name, and (b) import nothing
586             that is not required.  It can be quite painful to maintain
587             this property by hand, so this flag is intended to reduce
588             the labour.</para>
589           </listitem>
590         </varlistentry>
591
592         <varlistentry>
593           <term>
594             <option>--show-iface</option> <replaceable>file</replaceable>
595             <indexterm><primary><option>--show-iface</option></primary></indexterm>
596           </term>
597           <listitem>
598             <para>Where <replaceable>file</replaceable> is the name of
599             an interface file, dumps the contents of that interface in
600             a human-readable (ish) format.</para>
601           </listitem>
602         </varlistentry>
603       </variablelist>
604     </sect2>
605
606     <sect2 id="recomp">
607       <title>The recompilation checker</title>
608
609       <indexterm><primary>recompilation checker</primary></indexterm>
610
611       <variablelist>
612         <varlistentry>
613           <term>
614             <option>-fforce-recomp</option>
615             <indexterm><primary><option>-fforce-recomp</option></primary></indexterm>
616             <indexterm><primary><option>-fno-force-recomp</option></primary></indexterm>
617           </term>
618           <listitem>
619             <para>Turn off recompilation checking (which is on by
620             default).  Recompilation checking normally stops
621             compilation early, leaving an existing
622             <filename>.o</filename> file in place, if it can be
623             determined that the module does not need to be
624             recompiled.</para>
625           </listitem>
626         </varlistentry>
627       </variablelist>
628
629       <para>In the olden days, GHC compared the newly-generated
630       <filename>.hi</filename> file with the previous version; if they
631       were identical, it left the old one alone and didn't change its
632       modification date.  In consequence, importers of a module with
633       an unchanged output <filename>.hi</filename> file were not
634       recompiled.</para>
635
636       <para>This doesn't work any more.  Suppose module
637       <literal>C</literal> imports module <literal>B</literal>, and
638       <literal>B</literal> imports module <literal>A</literal>.  So
639       changes to module <literal>A</literal> might require module
640       <literal>C</literal> to be recompiled, and hence when
641       <filename>A.hi</filename> changes we should check whether
642       <literal>C</literal> should be recompiled.  However, the
643       dependencies of <literal>C</literal> will only list
644       <literal>B.hi</literal>, not <literal>A.hi</literal>, and some
645       changes to <literal>A</literal> (changing the definition of a
646       function that appears in an inlining of a function exported by
647       <literal>B</literal>, say) may conceivably not change
648       <filename>B.hi</filename> one jot.  So now&hellip;</para>
649
650       <para>GHC keeps a version number on each interface file, and on
651       each type signature within the interface file.  It also keeps in
652       every interface file a list of the version numbers of everything
653       it used when it last compiled the file.  If the source file's
654       modification date is earlier than the <filename>.o</filename>
655       file's date (i.e. the source hasn't changed since the file was
656       last compiled), and the recompilation checking is on, GHC will be
657       clever.  It compares the version numbers on the things it needs
658       this time with the version numbers on the things it needed last
659       time (gleaned from the interface file of the module being
660       compiled); if they are all the same it stops compiling rather
661       early in the process saying &ldquo;Compilation IS NOT
662       required&rdquo;.  What a beautiful sight!</para>
663
664       <para>Patrick Sansom had a workshop paper about how all this is
665       done (though the details have changed quite a bit). <ulink
666       url="mailto:sansom@dcs.gla.ac.uk">Ask him</ulink> if you want a
667       copy.</para>
668
669     </sect2>
670
671     <sect2 id="mutual-recursion">
672       <title>How to compile mutually recursive modules</title>
673
674       <indexterm><primary>module system, recursion</primary></indexterm>
675       <indexterm><primary>recursion, between modules</primary></indexterm>
676
677       <para>GHC supports the compilation of mutually recursive modules.
678       This section explains how.</para>
679
680       <para>Every cycle in the module import graph must be broken by a <filename>hs-boot</filename> file.
681       Suppose that modules <filename>A.hs</filename> and <filename>B.hs</filename> are Haskell source files, 
682       thus:
683 <programlisting>
684 module A where
685     import B( TB(..) )
686     
687     newtype TA = MkTA Int
688     
689     f :: TB -&#62; TA
690     f (MkTB x) = MkTA x
691
692 module B where
693     import {-# SOURCE #-} A( TA(..) )
694     
695     data TB = MkTB !Int
696     
697     g :: TA -&#62; TB
698     g (MkTA x) = MkTB x
699 </programlisting>
700 <indexterm><primary><literal>hs-boot</literal>
701       files</primary></indexterm> <indexterm><primary>importing,
702       <literal>hi-boot</literal> files</primary></indexterm>
703 Here <filename>A</filename> imports <filename>B</filename>, but <filename>B</filename> imports
704 <filename>A</filename> with a <literal>{-# SOURCE #-}</literal> pragma, which breaks the
705 circular dependency.  For every module <filename>A.hs</filename> that is <literal>{-# SOURCE #-}</literal>-imported
706 in this way there must exist a souce file <literal>A.hs-boot</literal>.  This file contains an abbreviated
707 version of <filename>A.hs</filename>, thus:
708 <programlisting>
709 module A where
710     newtype TA = MkTA Int
711 </programlisting>
712 </para>
713 <para>To compile these three files, issue the following commands:
714 <programlisting>
715   ghc -c A.hs-boot    -- Poduces A.hi-boot, A.o-boot
716   ghc -c B.hs         -- Consumes A.hi-boot, produces B.hi, B.o
717   ghc -c A.hs         -- Consumes B.hi, produces A.hi, A.o
718   ghc -o foo A.o B.o  -- Linking the program
719 </programlisting>
720 </para>
721 <para>There are several points to note here:
722 <itemizedlist>
723 <listitem>
724   <para>The file <filename>A.hs-boot</filename> is a programmer-written source file.
725   It must live in the same directory as its parent source file <filename>A.hs</filename>.
726   Currently, if you use a literate source file <filename>A.lhs</filename> you must
727   also use a literate boot file, <filename>A.lhs-boot</filename>; and vice versa.
728   </para></listitem>
729
730 <listitem><para>
731   A <filename>hs-boot</filename> file is compiled by GHC, just like a <filename>hs</filename> file:
732 <programlisting>
733   ghc -c A.hs-boot
734 </programlisting>
735 When a hs-boot file <filename>A.hs-boot</filename> 
736    is compiled, it is checked for scope and type errors.
737    When its parent module <filename>A.hs</filename> is compiled, the two are compared, and
738    an error is reported if the two are inconsistent.
739    </para></listitem>
740    
741         <listitem>
742           <para> Just as compiling <filename>A.hs</filename> produces an
743             interface file <filename>A.hi</filename>, and an object file
744             <filename>A.o</filename>, so compiling
745             <filename>A.hs-boot</filename> produces an interface file
746             <filename>A.hi-boot</filename>, and an pseudo-object file
747             <filename>A.o-boot</filename>: </para>
748
749           <itemizedlist>
750             <listitem>
751               <para>The pseudo-object file <filename>A.o-boot</filename> is
752                 empty (don't link it!), but it is very useful when using a
753                 Makefile, to record when the <filename>A.hi-boot</filename> was
754                 last brought up to date (see <xref
755                   linkend="using-make"/>).</para>
756             </listitem>
757
758             <listitem>
759               <para>The <filename>hi-boot</filename> generated by compiling a
760                 <filename>hs-boot</filename> file is in the same
761                 machine-generated binary format as any other GHC-generated
762                 interface file (e.g. <filename>B.hi</filename>). You can
763                 display its contents with <command>ghc
764                   --show-iface</command>. If you specify a directory for
765                 interface files, the <option>-ohidir</option> flag, then that
766                 affects <filename>hi-boot</filename> files
767                 too.</para>
768             </listitem>
769           </itemizedlist>
770         </listitem>
771
772    <listitem><para> If hs-boot files are considered distinct from their parent source
773    files, and if a <literal>{-# SOURCE #-}</literal> import is considered to refer to the
774    hs-boot file, then the module import graph must have no cycles.  The command
775    <command>ghc -M</command> will report an error if a cycle is found.
776    </para></listitem>
777
778    <listitem><para> A module <literal>M</literal> that is 
779    <literal>{-# SOURCE #-}</literal>-imported in a program will usually also be
780    ordinarily imported elsewhere.  If not, <command>ghc --make</command>
781    automatically adds <literal>M</literal> to the set of moudles it tries to
782    compile and link, to ensure that <literal>M</literal>'s implementation is included in
783    the final program.
784    </para></listitem>
785 </itemizedlist>
786 </para>
787 <para>
788 A hs-boot file need only contain the bare
789       minimum of information needed to get the bootstrapping process
790       started.  For example, it doesn't need to contain declarations
791       for <emphasis>everything</emphasis> that module
792       <literal>A</literal> exports, only the things required by the
793       module(s) that import <literal>A</literal> recursively.</para>
794 <para>A hs-boot file is written in a subset of Haskell:
795 <itemizedlist>
796 <listitem><para> The module header (including the export list), and import statements, are exactly as in
797 Haskell, and so are the scoping rules.  
798    Hence, to mention a non-Prelude type or class, you must import it.</para></listitem>
799    
800 <listitem><para> There must be no value declarations, but there can be type signatures for
801 values.  For example:
802 <programlisting>
803   double :: Int -&#62; Int
804 </programlisting>
805 </para></listitem>
806 <listitem><para> Fixity declarations are exactly as in Haskell.</para></listitem>
807 <listitem><para> Type synonym declarations are exactly as in Haskell.</para></listitem>
808 <listitem><para> A data type declaration can either be given in full, exactly as in Haskell, or it 
809 can be given abstractly, by omitting the '=' sign and everything that follows.  For example:
810 <programlisting>
811   data T a b
812 </programlisting>
813             In a <emphasis>source</emphasis> program
814           this would declare TA to have no constructors (a GHC extension: see <xref linkend="nullary-types"/>),
815           but in an hi-boot file it means "I don't know or care what the constructors are".
816             This is the most common form of data type declaration, because it's easy to get right.
817           You <emphasis>can</emphasis> also write out the constructors but, if you do so, you must write
818           it out precisely as in its real definition.</para>
819           <para>
820             If you do not write out the constructors, you may need to give a kind 
821             annotation (<xref linkend="kinding"/>), to tell
822             GHC the kind of the type variable, if it is not "*".  (In source files, this is worked out
823             from the way the type variable is used in the constructors.)  For example:
824 <programlisting>
825   data R (x :: * -&#62; *) y
826 </programlisting>
827 You cannot use <literal>deriving</literal> on a data type declaration; write in
828 <literal>instance</literal> declaration instead.
829 </para></listitem>
830 <listitem><para> Class declarations is exactly as in Haskell, except that you may not put
831 default method declarations.  You can also omit all the superclasses and class
832 methods entirely; but you must either omit them all or put them all in.
833 </para></listitem>
834 <listitem><para> You can include instance declarations just as in Haskell; but omit the "where" part.
835  </para></listitem>
836 </itemizedlist>
837 </para>
838     </sect2>
839
840
841     <sect2 id="using-make">
842       <title>Using <command>make</command></title>
843
844       <indexterm><primary><literal>make</literal></primary></indexterm>
845
846       <para>It is reasonably straightforward to set up a
847       <filename>Makefile</filename> to use with GHC, assuming you name
848       your source files the same as your modules.  Thus:</para>
849
850 <programlisting>
851 HC      = ghc
852 HC_OPTS = -cpp $(EXTRA_HC_OPTS)
853
854 SRCS = Main.lhs Foo.lhs Bar.lhs
855 OBJS = Main.o   Foo.o   Bar.o
856
857 .SUFFIXES : .o .hs .hi .lhs .hc .s
858
859 cool_pgm : $(OBJS)
860         rm -f $@
861         $(HC) -o $@ $(HC_OPTS) $(OBJS)
862
863 # Standard suffix rules
864 .o.hi:
865         @:
866
867 .lhs.o:
868         $(HC) -c $&#60; $(HC_OPTS)
869
870 .hs.o:
871         $(HC) -c $&#60; $(HC_OPTS)
872
873 .o-boot.hi-boot:
874         @:
875
876 .lhs-boot.o-boot:
877         $(HC) -c $&#60; $(HC_OPTS)
878
879 .hs-boot.o-boot:
880         $(HC) -c $&#60; $(HC_OPTS)
881
882 # Inter-module dependencies
883 Foo.o Foo.hc Foo.s    : Baz.hi          # Foo imports Baz
884 Main.o Main.hc Main.s : Foo.hi Baz.hi   # Main imports Foo and Baz
885 </programlisting>
886
887       <para>(Sophisticated <command>make</command> variants may
888       achieve some of the above more elegantly.  Notably,
889       <command>gmake</command>'s pattern rules let you write the more
890       comprehensible:</para>
891
892 <programlisting>
893 %.o : %.lhs
894         $(HC) -c $&#60; $(HC_OPTS)
895 </programlisting>
896
897       <para>What we've shown should work with any
898       <command>make</command>.)</para>
899
900       <para>Note the cheesy <literal>.o.hi</literal> rule: It records
901       the dependency of the interface (<filename>.hi</filename>) file
902       on the source.  The rule says a <filename>.hi</filename> file
903       can be made from a <filename>.o</filename> file by
904       doing&hellip;nothing.  Which is true.</para>
905       <para> Note that the suffix rules are all repeated twice, once
906       for normal Haskell source files, and once for <filename>hs-boot</filename>
907       files (see <xref linkend="mutual-recursion"/>).</para>
908
909       <para>Note also the inter-module dependencies at the end of the
910       Makefile, which take the form
911
912 <programlisting>
913 Foo.o Foo.hc Foo.s    : Baz.hi          # Foo imports Baz
914 </programlisting>
915
916       They tell <command>make</command> that if any of
917       <literal>Foo.o</literal>, <literal>Foo.hc</literal> or
918       <literal>Foo.s</literal> have an earlier modification date than
919       <literal>Baz.hi</literal>, then the out-of-date file must be
920       brought up to date.  To bring it up to date,
921       <literal>make</literal> looks for a rule to do so; one of the
922       preceding suffix rules does the job nicely.  These dependencies
923       can be generated automatically by <command>ghc</command>; see 
924       <xref linkend="makefile-dependencies"/></para>
925
926  </sect2>
927
928       <sect2 id="makefile-dependencies">
929         <title>Dependency generation</title>
930         <indexterm><primary>dependencies in Makefiles</primary></indexterm>
931         <indexterm><primary>Makefile dependencies</primary></indexterm>
932
933         <para>Putting inter-dependencies of the form <literal>Foo.o :
934         Bar.hi</literal> into your <filename>Makefile</filename> by
935         hand is rather error-prone.  Don't worry, GHC has support for
936         automatically generating the required dependencies.  Add the
937         following to your <filename>Makefile</filename>:</para>
938
939 <programlisting>
940 depend :
941         ghc -M $(HC_OPTS) $(SRCS)
942 </programlisting>
943
944         <para>Now, before you start compiling, and any time you change
945         the <literal>imports</literal> in your program, do
946         <command>make depend</command> before you do <command>make
947         cool&lowbar;pgm</command>.  The command <command>ghc -M</command> will
948         append the needed dependencies to your
949         <filename>Makefile</filename>.</para>
950
951         <para>In general, <command>ghc -M Foo</command> does the following.
952         For each module <literal>M</literal> in the set 
953         <literal>Foo</literal> plus all its imports (transitively),
954         it adds to the Makefile:
955         <itemizedlist>
956         <listitem><para>A line recording the dependence of the object file on the source file.
957 <programlisting>
958 M.o : M.hs
959 </programlisting>
960 (or <literal>M.lhs</literal> if that is the filename you used).
961        </para></listitem>
962        <listitem><para> For each import declaration <literal>import X</literal> in <literal>M</literal>,
963        a line recording the dependence of <literal>M</literal> on <literal>X</literal>:
964 <programlisting>
965 M.o : X.hi
966 </programlisting></para></listitem>
967        <listitem><para> For each import declaration <literal>import {-# SOURCE #-} X</literal> in <literal>M</literal>,
968        a line recording the dependence of <literal>M</literal> on <literal>X</literal>:
969 <programlisting>
970 M.o : X.hi-boot
971 </programlisting>
972        (See <xref linkend="mutual-recursion"/> for details of
973        <literal>hi-boot</literal> style interface files.)
974       </para></listitem>
975         </itemizedlist> 
976         If <literal>M</literal> imports multiple modules, then there will
977        be multiple lines with <filename>M.o</filename> as the
978        target.</para>
979        <para>There is no need to list all of the source files as arguments to the <command>ghc -M</command> command;
980        <command>ghc</command> traces the dependencies, just like <command>ghc --make</command>
981        (a new feature in GHC 6.4).</para>
982
983     <para>Note that <literal>ghc -M</literal> needs to find a <emphasis>source
984         file</emphasis> for each module in the dependency graph, so that it can
985       parse the import declarations and follow dependencies.  Any pre-compiled
986       modules without source files must therefore belong to a
987       package<footnote><para>This is a change in behaviour relative to 6.2 and
988         earlier.</para>
989       </footnote>.</para>
990
991         <para>By default, <command>ghc -M</command> generates all the
992         dependencies, and then concatenates them onto the end of
993         <filename>makefile</filename> (or
994         <filename>Makefile</filename> if <filename>makefile</filename>
995         doesn't exist) bracketed by the lines "<literal>&num; DO NOT
996         DELETE: Beginning of Haskell dependencies</literal>" and
997         "<literal>&num; DO NOT DELETE: End of Haskell
998         dependencies</literal>".  If these lines already exist in the
999         <filename>makefile</filename>, then the old dependencies are
1000         deleted first.</para>
1001
1002         <para>Don't forget to use the same <option>-package</option>
1003         options on the <literal>ghc -M</literal> command line as you
1004         would when compiling; this enables the dependency generator to
1005         locate any imported modules that come from packages.  The
1006         package modules won't be included in the dependencies
1007         generated, though (but see the
1008         <option>&ndash;&ndash;include-pkg-deps</option> option below).</para>
1009
1010         <para>The dependency generation phase of GHC can take some
1011         additional options, which you may find useful.  For historical
1012         reasons, each option passed to the dependency generator from
1013         the GHC command line must be preceded by
1014         <literal>-optdep</literal>.  For example, to pass <literal>-f
1015         .depend</literal> to the dependency generator, you say
1016
1017 <screen>
1018 ghc -M -optdep-f -optdep.depend ...
1019 </screen>
1020
1021         The options which affect dependency generation are:</para>
1022
1023         <variablelist>
1024           <varlistentry>
1025             <term><option>-ddump-mod-cycles</option></term>
1026             <listitem>
1027               <para>Display a list of the cycles in the module graph. This is
1028           useful when trying to eliminate such cycles.  You do not need the <literal>-optdep</literal> prefix
1029           for this flag.</para>
1030             </listitem>
1031           </varlistentry>
1032
1033           <varlistentry>
1034             <term><option>-w</option></term>
1035             <listitem>
1036               <para>Turn off warnings about interface file shadowing.</para>
1037             </listitem>
1038           </varlistentry>
1039
1040           <varlistentry>
1041             <term><option>-v2</option></term>
1042             <listitem>
1043               <para>Print a full list of the module depenencies to stdout.
1044                     (This is the standard verbosity flag, so the list will
1045               also be displayed with <option>-v3</option> and
1046               <option>-v4</option>;
1047               <xref linkend ="options-help"/>.)</para>
1048             </listitem>
1049           </varlistentry>
1050
1051           <varlistentry>
1052             <term><option>-f</option> <replaceable>file</replaceable></term>
1053             <listitem>
1054               <para>Use <replaceable>file</replaceable> as the makefile,
1055               rather than <filename>makefile</filename> or
1056               <filename>Makefile</filename>.  If
1057               <replaceable>file</replaceable> doesn't exist,
1058               <command>mkdependHS</command> creates it.  We often use
1059               <option>-f .depend</option> to put the dependencies in
1060               <filename>.depend</filename> and then
1061               <command>include</command> the file
1062               <filename>.depend</filename> into
1063               <filename>Makefile</filename>.</para>
1064             </listitem>
1065           </varlistentry>
1066
1067 <!-- Retired with the move away from 'mkdependHS'.
1068           <varlistentry>
1069             <term><option>-o &lt;osuf&gt;</option></term>
1070             <listitem>
1071               <para>Use <filename>.&lt;osuf&gt;</filename> as the
1072               "target file" suffix ( default: <literal>o</literal>).
1073               Multiple <option>-o</option> flags are permitted
1074               (GHC2.05 onwards).  Thus "<option>-o hc -o o</option>"
1075               will generate dependencies for <filename>.hc</filename>
1076               and <filename>.o</filename> files.</para>
1077             </listitem>
1078           </varlistentry>
1079 -->
1080           <varlistentry>
1081             <term><option>-s &lt;suf&gt;</option></term>
1082             <listitem>
1083               <para>Make extra dependencies that declare that files
1084               with suffix
1085               <filename>.&lt;suf&gt;&lowbar;&lt;osuf&gt;</filename>
1086               depend on interface files with suffix
1087               <filename>.&lt;suf&gt;&lowbar;hi</filename>, or (for
1088               <literal>&lcub;-&num; SOURCE &num;-&rcub;</literal>
1089               imports) on <filename>.hi-boot</filename>.  Multiple
1090               <option>-s</option> flags are permitted.  For example,
1091               <option>-o hc -s a -s b</option> will make dependencies
1092               for <filename>.hc</filename> on
1093               <filename>.hi</filename>,
1094               <filename>.a&lowbar;hc</filename> on
1095               <filename>.a&lowbar;hi</filename>, and
1096               <filename>.b&lowbar;hc</filename> on
1097               <filename>.b&lowbar;hi</filename>.  (Useful in
1098               conjunction with NoFib "ways".)</para>
1099             </listitem>
1100           </varlistentry>
1101
1102           <varlistentry>
1103             <term><option>&ndash;&ndash;exclude-module=&lt;file&gt;</option></term>
1104             <listitem>
1105               <para>Regard <filename>&lt;file&gt;</filename> as
1106               "stable"; i.e., exclude it from having dependencies on
1107               it.</para>
1108             </listitem>
1109           </varlistentry>
1110
1111           <varlistentry>
1112             <term><option>-x</option></term>
1113             <listitem>
1114               <para>same as <option>&ndash;&ndash;exclude-module</option></para>
1115             </listitem>
1116           </varlistentry>
1117
1118 <!-- Not currently implemented:
1119           <varlistentry>
1120             <term><option>&ndash;&ndash;exclude-directory=&lt;dirs&gt;</option></term>
1121             <listitem>
1122               <para>Regard the colon-separated list of directories
1123               <filename>&lt;dirs&gt;</filename> as containing stable,
1124               don't generate any dependencies on modules
1125               therein.</para>
1126             </listitem>
1127           </varlistentry>
1128
1129           <varlistentry>
1130             <term><option>&ndash;&ndash;include-module=&lt;file&gt;</option></term>
1131             <listitem>
1132               <para>Regard <filename>&lt;file&gt;</filename> as not
1133               "stable"; i.e., generate dependencies on it (if
1134               any). This option is normally used in conjunction with
1135               the <option>&ndash;&ndash;exclude-directory</option> option.</para>
1136             </listitem>
1137           </varlistentry>
1138 -->
1139
1140           <varlistentry>
1141             <term><option>&ndash;&ndash;include-pkg-deps</option></term>
1142             <listitem>
1143               <para>Regard modules imported from packages as unstable,
1144               i.e., generate dependencies on any imported package modules
1145               (including <literal>Prelude</literal>, and all other
1146               standard Haskell libraries).  Dependencies are not traced
1147               recursively into packages; dependencies are only generated for
1148               home-package modules on external-package modules directly imported
1149               by the home package module.
1150               This option is normally
1151               only used by the various system libraries.</para>
1152             </listitem>
1153           </varlistentry>
1154         </variablelist>
1155
1156     </sect2>
1157
1158     <sect2 id="orphan-modules">
1159       <title>Orphan modules and instance declarations</title>
1160
1161 <para> Haskell specifies that when compiling module M, any instance
1162 declaration in any module "below" M is visible.  (Module A is "below"
1163 M if A is imported directly by M, or if A is below a module that M imports directly.)
1164 In principle, GHC must therefore read the interface files of every module below M,
1165 just in case they contain an instance declaration that matters to M.  This would
1166 be a disaster in practice, so GHC tries to be clever. </para>
1167
1168 <para>In particular, if an instance declaration is in the same module as the definition
1169 of any type or class mentioned in the head of the instance declaration, then
1170 GHC has to visit that interface file anyway.  Example:</para>
1171 <programlisting>
1172   module A where
1173     instance C a =&gt; D (T a) where ...
1174     data T a = ...
1175 </programlisting>
1176 <para> The instance declaration is only relevant if the type T is in use, and if
1177 so, GHC will have visited A's interface file to find T's definition. </para>
1178
1179 <para> The only problem comes when a module contains an instance declaration
1180 and GHC has no other reason for visiting the module.  Example:
1181 <programlisting>
1182   module Orphan where
1183     instance C a =&gt; D (T a) where ...
1184     class C a where ...
1185 </programlisting>
1186 Here, neither D nor T is declared in module Orphan.
1187 We call such modules ``orphan modules'',
1188 defined thus:</para>
1189 <itemizedlist>
1190   <listitem> <para> An <emphasis>orphan module</emphasis>
1191   <indexterm><primary>orphan module</primary></indexterm>
1192   contains at least one <emphasis>orphan instance</emphasis> or at
1193   least one <emphasis>orphan rule</emphasis>.</para> </listitem>
1194
1195   <listitem><para> An instance declaration in a module M is an <emphasis>orphan instance</emphasis> if
1196   <indexterm><primary>orphan instance</primary></indexterm>
1197   none of the type constructors
1198   or classes mentioned in the instance head (the part after the ``<literal>=&gt;</literal>'') are declared
1199   in M.</para>
1200
1201   <para> Only the instance head counts.  In the example above, it is not good enough for C's declaration
1202   to be in module A; it must be the declaration of D or T.</para>
1203   </listitem>
1204
1205   <listitem><para> A rewrite rule in a module M is an <emphasis>orphan rule</emphasis>
1206   <indexterm><primary>orphan rule</primary></indexterm>
1207   if none of the variables, type constructors,
1208   or classes that are free in the left hand side of the rule are declared in M.
1209   </para> </listitem>
1210  </itemizedlist>
1211
1212
1213 <para> GHC identifies orphan modules, and visits the interface file of
1214 every orphan module below the module being compiled.  This is usually
1215 wasted work, but there is no avoiding it.  You should therefore do
1216 your best to have as few orphan modules as possible.
1217
1218 </para>
1219
1220 <para> You can identify an orphan module by looking in its interface
1221 file, <filename>M.hi</filename>, using the
1222 <option>--show-iface</option>.  If there is a ``!'' on the first line,
1223 GHC considers it an orphan module.
1224 </para>
1225 </sect2>
1226
1227   </sect1>
1228
1229 <!-- Emacs stuff:
1230      ;;; Local Variables: ***
1231      ;;; mode: xml ***
1232      ;;; sgml-parent-document: ("users_guide.xml" "book" "chapter" "sect1") ***
1233      ;;; End: ***
1234  -->