[project @ 2005-03-07 13:18:51 by simonmar]
[ghc-hetmet.git] / ghc / docs / users_guide / using.xml
index ffe639c..80b8790 100644 (file)
@@ -51,35 +51,38 @@ ghc [argument...]
       <option>-fglasgow-exts</option> option.  Rather than maintaining
       the list of per-file options in a <filename>Makefile</filename>,
       it is possible to do this directly in the source file using the
-      <literal>OPTIONS</literal> pragma <indexterm><primary>OPTIONS
+      <literal>OPTIONS_GHC</literal> pragma <indexterm><primary>OPTIONS_GHC
       pragma</primary></indexterm>:</para>
 
 <programlisting>
-{-# OPTIONS -fglasgow-exts #-}
+{-# OPTIONS_GHC -fglasgow-exts #-}
 module X where
 ...
 </programlisting>
       
-      <para><literal>OPTIONS</literal> pragmas are only looked for at
+      <para><literal>OPTIONS_GHC</literal> pragmas are only looked for at
       the top of your source files, upto the first
       (non-literate,non-empty) line not containing
-      <literal>OPTIONS</literal>. Multiple <literal>OPTIONS</literal>
-      pragmas are recognised. Note that your command shell does not
+      <literal>OPTIONS_GHC</literal>. Multiple <literal>OPTIONS_GHC</literal>
+      pragmas are recognised.  Do not put comments before, or on the same line
+       as, the <literal>OPTIONS_GHC</literal> pragma.</para>
+
+      <para>Note that your command shell does not
       get to the source file options, they are just included literally
-      in the array of command-line arguments the compiler driver
+      in the array of command-line arguments the compiler
       maintains internally, so you'll be desperately disappointed if
-      you try to glob etc. inside <literal>OPTIONS</literal>.</para>
+      you try to glob etc. inside <literal>OPTIONS_GHC</literal>.</para>
 
-      <para>NOTE: the contents of OPTIONS are prepended to the
+      <para>NOTE: the contents of OPTIONS_GHC are prepended to the
       command-line options, so you <emphasis>do</emphasis> have the
-      ability to override OPTIONS settings via the command
+      ability to override OPTIONS_GHC settings via the command
       line.</para>
 
       <para>It is not recommended to move all the contents of your
       Makefiles into your source files, but in some circumstances, the
-      <literal>OPTIONS</literal> pragma is the Right Thing. (If you
+      <literal>OPTIONS_GHC</literal> pragma is the Right Thing. (If you
       use <option>-keep-hc-file-too</option> and have OPTION flags in
-      your module, the OPTIONS will get put into the generated .hc
+      your module, the OPTIONS_GHC will get put into the generated .hc
       file).</para>
     </sect2>
 
@@ -102,7 +105,7 @@ module X where
     <para>Each of GHC's command line options is classified as either
     <firstterm>static</firstterm> or <firstterm>dynamic</firstterm>.
     A static flag may only be specified on the command line, whereas a
-    dynamic flag may also be given in an <literal>OPTIONS</literal>
+    dynamic flag may also be given in an <literal>OPTIONS_GHC</literal>
     pragma in a source file or set from the GHCi command-line with
     <literal>:set</literal>.</para>
 
@@ -354,7 +357,7 @@ ghc &ndash;&ndash;make Main.hs
       <option>&ndash;&ndash;make</option>, but note that any options
       you give on the command line will apply to all the source files
       compiled, so if you want any options to apply to a single source
-      file only, you'll need to use an <literal>OPTIONS</literal>
+      file only, you'll need to use an <literal>OPTIONS_GHC</literal>
       pragma (see <xref linkend="source-file-options"/>).</para>
 
       <para>If the program needs to be linked with additional objects
@@ -835,6 +838,33 @@ g [] = 2
       </varlistentry>
 
       <varlistentry>
+       <term><option>-fwarn-incomplete-record-updates</option>:</term>
+       <listitem>
+         <indexterm><primary><option>-fwarn-incomplete-record-updates</option></primary></indexterm>
+         <indexterm><primary>incomplete record updates, warning</primary></indexterm>
+         <indexterm><primary>record updates, incomplete</primary></indexterm>
+
+         <para>The function
+          <function>f</function> below will fail when applied to
+          <literal>Bar</literal>, so the compiler will emit a warning about
+          this when <option>-fwarn-incomplete-record-updates</option> is
+          enabled.</para>
+
+<programlisting>
+data Foo = Foo { x :: Int }
+         | Bar
+
+f :: Foo -> Foo
+f foo = foo { x = 6 }
+</programlisting>
+
+         <para>This option isn't enabled be default because it can be
+          very noisy, and it often doesn't indicate a bug in the
+          program.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
        <term>
           <option>-fwarn-misc</option>:
           <indexterm><primary><option>-fwarn-misc</option></primary></indexterm>
@@ -923,6 +953,27 @@ g [] = 2
       </varlistentry>
 
       <varlistentry>
+       <term><option>-fwarn-orphans</option>:</term>
+       <listitem>
+         <indexterm><primary><option>-fwarn-orphans</option></primary></indexterm>
+         <indexterm><primary>orphan instances, warning</primary></indexterm>
+         <indexterm><primary>orphan rules, warning</primary></indexterm>
+         
+         <para>This option causes a warning to be emitted whenever the 
+           module contains an "orphan" instance declaration or rewrite rule.
+           An instance declartion is an orphan if it appears in a module in
+           which neither the class nor the type being instanced are declared
+           in the same module.  A rule is an orphan if it is a rule for a
+           function declared in another module.  A module containing any
+         orphans is called an orphan module.</para>
+         <para>The trouble with orphans is that GHC must pro-actively read the interface
+           files for all orphan modules, just in case their instances or rules
+           play a role, whether or not the module's interface would otherwise 
+           be of any use.  Other things being equal, avoid orphan modules.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
        <term>
           <option>-fwarn-overlapping-patterns</option>:
           <indexterm><primary><option>-fwarn-overlapping-patterns</option></primary></indexterm>
@@ -1823,7 +1874,7 @@ ordinary Haskell 98, when translated to External Core, uses things like rank-2 t
 
 <!-- Emacs stuff:
      ;;; Local Variables: ***
-     ;;; mode: sgml ***
+     ;;; mode: xml ***
      ;;; sgml-parent-document: ("users_guide.xml" "book" "chapter") ***
      ;;; End: ***
  -->