<replaceable>dir</replaceable>. For example:</para>
<screen>
-$ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch`
+$ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `uname -m`
</screen>
<para>The object files, <filename>Foo.o</filename>,
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <option>-outputdir</option> <replaceable>dir</replaceable>
+ <indexterm><primary><option>-outputdir</option></primary></indexterm>
+ </term>
+ <listitem>
+ <para>The <option>-outputdir</option> option is shorthand for
+ the combination
+ of <option>-odir</option>, <option>-hidir</option>,
+ and <option>-stubdir</option>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>
<option>-osuf</option> <replaceable>suffix</replaceable>
the same as the old one; this is friendly to
<command>make</command>. When an interface does change,
it is often enlightening to be informed. The
- <option>-ddump-hi-diffs</option> option will make GHC run
- <command>diff</command> on the old and new
- <filename>.hi</filename> files.</para>
+ <option>-ddump-hi-diffs</option> option will make GHC
+ report the differences between the old and
+ new <filename>.hi</filename> files.</para>
</listitem>
</varlistentry>
<literal>B</literal>, say) may conceivably not change
<filename>B.hi</filename> one jot. So now…</para>
- <para>GHC keeps a version number on each interface file, and on
- each type signature within the interface file. It also keeps in
- every interface file a list of the version numbers of everything
- it used when it last compiled the file. If the source file's
- modification date is earlier than the <filename>.o</filename>
- file's date (i.e. the source hasn't changed since the file was
- last compiled), and the recompilation checking is on, GHC will be
- clever. It compares the version numbers on the things it needs
- this time with the version numbers on the things it needed last
- time (gleaned from the interface file of the module being
- compiled); if they are all the same it stops compiling rather
- early in the process saying “Compilation IS NOT
- required”. What a beautiful sight!</para>
-
- <para>Patrick Sansom had a workshop paper about how all this is
- done (though the details have changed quite a bit). <ulink
- url="mailto:sansom@dcs.gla.ac.uk">Ask him</ulink> if you want a
- copy.</para>
+ <para>GHC calculates a fingerprint (in fact an MD5 hash) of each
+ interface file, and of each declaration within the interface
+ file. It also keeps in every interface file a list of the
+ fingerprints of everything it used when it last compiled the
+ file. If the source file's modification date is earlier than
+ the <filename>.o</filename> file's date (i.e. the source hasn't
+ changed since the file was last compiled), and the recompilation
+ checking is on, GHC will be clever. It compares the fingerprints
+ on the things it needs this time with the fingerprints
+ on the things it needed last time (gleaned from the
+ interface file of the module being compiled); if they are all
+ the same it stops compiling early in the process saying
+ “Compilation IS NOT required”. What a beautiful
+ sight!</para>
+
+ <para>You can read
+ about <ulink url="http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/RecompilationAvoidance">how
+ all this works</ulink> in the GHC commentary.</para>
</sect2>
<literal>hi-boot</literal> files</primary></indexterm>
Here <filename>A</filename> imports <filename>B</filename>, but <filename>B</filename> imports
<filename>A</filename> with a <literal>{-# SOURCE #-}</literal> pragma, which breaks the
-circular dependency. For every module <filename>A.hs</filename> that is <literal>{-# SOURCE #-}</literal>-imported
+circular dependency. Every loop in the module import graph must be broken by a <literal>{-# SOURCE #-}</literal> import;
+or, equivalently, the module import graph must be acyclic if <literal>{-# SOURCE #-}</literal> imports are ignored.
+</para>
+<para>For every module <filename>A.hs</filename> that is <literal>{-# SOURCE #-}</literal>-imported
in this way there must exist a source file <literal>A.hs-boot</literal>. This file contains an abbreviated
version of <filename>A.hs</filename>, thus:
<programlisting>
be a disaster in practice, so GHC tries to be clever. </para>
<para>In particular, if an instance declaration is in the same module as the definition
-of any type or class mentioned in the head of the instance declaration, then
+of any type or class mentioned in the <emphasis>head</emphasis> of the instance declaration
+(the part after the “<literal>=></literal>”; see <xref linkend="instance-rules"/>), then
GHC has to visit that interface file anyway. Example:</para>
<programlisting>
module A where
class E x y | y -> x where ...
</programlisting>
Then in some importing module M, the constraint <literal>(E a Int)</literal> should be "improved" by setting
-<literal>a = Int</literal>, <emphasis>even though there is no explicit mention
+<literal>a = T</literal>, <emphasis>even though there is no explicit mention
of <literal>T</literal> in M</emphasis>.</para>
These considerations lead to the following definition of an orphan module:
</para></listitem>
</itemizedlist>
</para>
- <para> Only the instance head (the part after the “<literal>=></literal>”)
+ <para> Only the instance head
counts. In the example above, it is not good enough for C's declaration
to be in module A; it must be the declaration of D or T.</para>
</listitem>
-<para>GHC will warn you if you are creating an orphan module, if you add `-fwarn-orphan-modules`.
+<para>If you use the flag <option>-fwarn-orphans</option>, GHC will warn you
+if you are creating an orphan module.
+Like any warning, you can switch the warning off with <option>-fno-warn-orphans</option>,
+and <option>-Werror</option>
+will make the compilation fail if the warning is issued.
+</para>
+<para>
You can identify an orphan module by looking in its interface
file, <filename>M.hi</filename>, using the
<link linkend="modes"><option>--show-iface</option> mode</link>. If there is a <literal>[orphan module]</literal> on the