Improve docs for orphan decls (thanks Yitzchak Gale)
[ghc-hetmet.git] / docs / users_guide / separate_compilation.xml
index fc22fbd..bc3afca 100644 (file)
@@ -702,7 +702,10 @@ module B where
       <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>
@@ -1166,7 +1169,8 @@ just in case they contain an instance declaration that matters to M.  This would
 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 &ldquo;<literal>=&gt;</literal>&rdquo;; see <xref linkend="instance-rules"/>), then
 GHC has to visit that interface file anyway.  Example:</para>
 <programlisting>
   module A where
@@ -1205,7 +1209,7 @@ functional dependency:
     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:
@@ -1229,7 +1233,7 @@ These considerations lead to the following definition of an orphan module:
        </para></listitem>
   </itemizedlist>
   </para>
-  <para> Only the instance head  (the part after the &ldquo;<literal>=&gt;</literal>&rdquo;)
+  <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>