[project @ 2001-01-04 10:48:46 by simonmar]
[ghc-hetmet.git] / ghc / docs / users_guide / using.sgml
index 93a5a52..019e89d 100644 (file)
@@ -275,12 +275,15 @@ over your Haskell source file before continuing.
 </Para>
 
 <Para>
-The option <Option>-E</Option><IndexTerm><Primary>-E option</Primary></IndexTerm> runs just the pre-processing
-passes of the compiler, outputting the result on stdout before
-stopping. If used in conjunction with -cpp, the output is the
+The option <Option>-E</Option><IndexTerm><Primary>-E
+option</Primary></IndexTerm> runs just the pre-processing passes of
+the compiler, dumping the result in a file.  Note that this differs
+from all GHCs prior to version 4.11, in which the result was dumped to the
+standard output.  If used in conjunction with -cpp, the output is the
 code blocks of the original (literal) source after having put it
-through the grinder that is the C pre-processor. Sans <Option>-cpp</Option>, the
-output is the de-litted version of the original source.
+through the grinder that is the C pre-processor. Sans
+<Option>-cpp</Option>, the output is the de-litted version of the
+original source.
 </Para>
 
 <Para>
@@ -889,9 +892,41 @@ resets the &ldquo;import directories&rdquo; list back to nothing.
 <Para>
 <IndexTerm><Primary>-fno-implicit-prelude option</Primary></IndexTerm>
 GHC normally imports <Filename>Prelude.hi</Filename> files for you.  If you'd rather it
-didn't, then give it a <Option>-fno-implicit-prelude</Option> option.  You are
-unlikely to get very far without a Prelude, but, hey, it's a free
-country.
+didn't, then give it a <Option>-fno-implicit-prelude</Option> option.  
+The idea is that you can then import a Prelude of your own.  (But don't call it <Literal>Prelude</Literal>;
+the Haskell module namespace is flat, and you must not conflict with any Prelude module.)
+</Para>
+<Para>
+Even though you have not imported the Prelude, all the built-in syntax still refers to 
+the built-in Haskell Prelude types and values, as specified by the Haskell Report.  
+For example, the type <Literal>[Int]</Literal>
+still means <Literal>Prelude.[] Int</Literal>; tuples continue to refer to the standard Prelude
+tuples; the translation for list comprehensions continues to use <Literal>Prelude.map</Literal> etc.
+</Para>
+<Para> With one group of exceptions!  You may want to define your own numeric class hierarchy.
+It completely defeats that purpose if the literal "1" means "<Literal>Prelude.fromInteger 1</Literal>",
+which is what the Haskell Report specifies.  So the <Option>-fno-implicit-prelude</Option> flag causes
+the following pieces of built-in syntax to refer to whatever is in scope, not the Prelude versions:
+<ItemizedList>
+<ListItem>
+<Para>
+Integer and fractional literals mean "<Literal>fromInteger 1</Literal>" and "<Literal>fromRational 3.2</Literal>",
+not the Prelude-qualified versions; both in expressions and in patterns.
+</Para>
+</ListItem>
+<ListItem>
+<Para>
+Negation (e.g. "<Literal>- (f x)</Literal>") means "<Literal>negate (f x)</Literal>" (not <Literal>Prelude.negate</Literal>).
+</Para>
+</ListItem>
+<ListItem>
+<Para>
+In an n+k pattern, the standard Prelude <Literal>Ord</Literal> class is used for comparison, but the 
+necessary subtraction uses 
+whatever "<Literal>(-)</Literal>" is in scope (not "<Literal>Prelude.(-)</Literal>").
+</Para>
+</ListItem>
+</ItemizedList>
 </Para>
 </ListItem>
 </VarListEntry>
@@ -1669,34 +1704,38 @@ construction of interface files, is (allegedly) in the works.
       <para>A package specification looks like this:</para>
 
 <screen>
- ("mypkg",
-  "4.08",
-  Package
-       {
-        import_dirs    =  ["/usr/local/lib/imports/mypkg"],
-       library_dirs   =  ["/usr/local/lib"],
-       libraries      =  ["HSmypkg", "HSmypkg_cbits"],
-       include_dirs   =  [],
-       c_includes     =  ["HsMyPkg.h"],
-       package_deps   =  ["text", "data"],
-       extra_ghc_opts =  [],
-       extra_cc_opts  =  [],
-       extra_ld_opts  =  ["-lmy_clib"]
-       }
- )
+  Package {
+     name            = "mypkg",
+     import_dirs     = ["/usr/local/lib/imports/mypkg"],
+     library_dirs    = ["/usr/local/lib"],
+     hs_libraries    = ["HSmypkg" ],
+     extra_libraries = ["HSmypkg_cbits"],
+     include_dirs    = [],
+     c_includes      = ["HsMyPkg.h"],
+     package_deps    = ["text", "data"],
+     extra_ghc_opts  = [],
+     extra_cc_opts   = [],
+     extra_ld_opts   = ["-lmy_clib"]
+  }
 </screen>
 
-      <para>The first line is the name of the package, for use with
-      the <literal>-package</literal> flag and as listed in the
-      <literal>--list-packages</literal> list.  The second line is the
-      version of GHC that was used to compile any Haskell code in this
-      package (GHC will refuse to add the package if its version
-      number differs from this one).  The rest of the components of
-      the package specification may be specified in any order, and
-      are:</para>
+      <para>Components of a package specification may be specified in
+      any order, and are:</para>
 
       <variablelist>
        <varlistentry>
+         <term><literal>name</literal></term>
+         <indexterm><primary><literal>name</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+            <para>The package's name, for use with
+            the <literal>-package</literal> flag and as listed in the
+            <literal>--list-packages</literal> list. 
+            </para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
          <term><literal>import_dirs</literal></term>
          <indexterm><primary><literal>import_dirs</literal></primary>
            <secondary>package specification</secondary></indexterm>
@@ -1717,14 +1756,42 @@ construction of interface files, is (allegedly) in the works.
        </varlistentry>
 
        <varlistentry>
-         <term><literal>libraries</literal></term>
-         <indexterm><primary><literal>libraries</literal></primary>
+         <term><literal>hs_libraries</literal></term>
+         <indexterm><primary><literal>hs_libraries</literal></primary>
            <secondary>package specification</secondary></indexterm>
          <listitem>
-           <para>A list of libraries for this package, with the
-           <literal>.a</literal> or <literal>.dll</literal> suffix
-           omitted.  On Unix, the <literal>lib</literal> prefix is
-           also omitted.</para>
+           <para>A list of libraries containing Haskell code for this
+           package, with the <literal>.a</literal> or
+           <literal>.dll</literal> suffix omitted.  On Unix, the
+           <literal>lib</literal> prefix is also omitted.</para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term><literal>extra_libraries</literal></term>
+         <indexterm><primary><literal>extra_libraries</literal></primary>
+           <secondary>package specification</secondary></indexterm>
+         <listitem>
+           <para>A list of extra libraries for this package.  The
+           difference between <literal>hs_libraries</literal> and
+           <literal>extra_libraries</literal> is that
+           <literal>hs_libraries</literal> normally have several
+           versions, to support profiling, parallel and other build
+           options.  The various versions are given different
+           suffixes to distinguish them, for example the profiling
+           version of the standard prelude library is named
+           <filename>libHSstd_p.a</filename>, with the
+           <literal>_p</literal> indicating that this is a profiling
+           version.  The suffix is added automatically by GHC for
+           <literal>hs_libraries</literal> only, no suffix is added
+           for libraries in
+           <literal>extra_libraries</literal>.</para>
+
+           <para>Also, <literal>extra_libraries</literal> are placed
+           on the linker command line before the
+           <literal>hs_libraries</literal> for the same package.  If
+           your package has dependencies in the other direction, you
+           might need to make two separate packages.</para>
          </listitem>
        </varlistentry>
 
@@ -2085,27 +2152,23 @@ apply (see <Option>-funfolding-con-discount</Option>).
 </Para>
 </ListItem>
 </VarListEntry>
+
 <VarListEntry>
-<Term><Option>-funfolding-con-discount&lt;n&gt;</Option>:</Term>
+<Term><Option>-funfolding-update-in-place&lt;n&gt;</Option>:</Term>
 <ListItem>
 <Para>
-<IndexTerm><Primary>-funfolding-con-discount option</Primary></IndexTerm>
-<IndexTerm><Primary>inlining, controlling</Primary></IndexTerm>
-<IndexTerm><Primary>unfolding, controlling</Primary></IndexTerm>
-(Default: 2) If the compiler decides that it can eliminate some
-computation by performing an unfolding, then this is a discount factor
-that it applies to the funciton size before deciding whether to unfold
-it or not.
-</Para>
-
-<Para>
-OK, folks, these magic numbers `30', `8', and '2' are mildly
-arbitrary; they are of the &ldquo;seem to be OK&rdquo; variety.  The `8' is the
-more critical one; it's what determines how eager GHC is about
-expanding unfoldings.
+Switches on an experimental "optimisation".  Switching it on makes the compiler
+a little keener to inline a function that returns a constructor, if the context is
+that of a thunk.
+<ProgramListing>
+   x = plusInt a b
+</ProgramListing>
+If we inlined plusInt we might get an opportunity to use update-in-place for
+the thunk 'x'.
 </Para>
 </ListItem>
 </VarListEntry>
+
 <VarListEntry>
 <Term><Option>-funbox-strict-fields</Option>:</Term>
 <ListItem>
@@ -2203,6 +2266,18 @@ We have not played with <Option>-fsemi-tagging</Option> enough to recommend it.
 </Para>
 </ListItem>
 </VarListEntry>
+<VarListEntry>
+<Term><Option>-fexcess-precision</Option>:</Term>
+<ListItem>
+<Para>
+When this option is given, intermediate floating point values can have
+a <Emphasis>greater</Emphasis> precision/range than the final type.
+Generally this is a good thing, but some programs may rely on the
+exact precision/range of <Literal>Float</Literal>/<Literal>Double</Literal>
+values and should not use this option for their compilation.
+</Para>
+</ListItem>
+</VarListEntry>
 </VariableList>
 </Para>
 
@@ -2634,9 +2709,10 @@ libraries automatically; these are:
 </Para>
 
 <Para>
-If you are using a Haskell &ldquo;system library&rdquo; (e.g., the POSIX
-library), just use the <Option>-package posix</Option> option, and the correct code
-should be linked in.
+If you are using a Haskell &ldquo;package&rdquo; (e.g., the POSIX
+library), just use the <Option>-package posix</Option> option, and the
+correct code should be linked in.  See <xref linkend="packages"> for
+more details.
 </Para>
 </ListItem>
 </VarListEntry>
@@ -2952,21 +3028,16 @@ the default is 2.
 <Term><Option>-C[&lt;us&gt;]</Option>:</Term>
 <ListItem>
 <Para>
-<IndexTerm><Primary>-C&lt;us&gt; RTS option</Primary></IndexTerm>
-Sets the context switch interval to <Literal>&lt;us&gt;</Literal> microseconds.  A context
-switch will occur at the next heap allocation after the timer expires.
-With <Option>-C0</Option> or <Option>-C</Option>, context switches will occur as often as
-possible (at every heap allocation).  By default, context switches
-occur every 10 milliseconds.  Note that many interval timers are only
-capable of 10 millisecond granularity, so the default setting may be
-the finest granularity possible, short of a context switch at every
-heap allocation.
-</Para>
-
-<Para>
-&lsqb;NOTE: this option currently has no effect (version 4.00).  Context
-switches happen when the current heap block is full, i.e. every 4k of
-allocation].
+<IndexTerm><Primary>-C&lt;us&gt; RTS option</Primary></IndexTerm> Sets
+the context switch interval to <Literal>&lt;s&gt;</Literal> seconds.
+A context switch will occur at the next heap block allocation after
+the timer expires (a heap block allocation occurs every 4k of
+allocation).  With <Option>-C0</Option> or <Option>-C</Option>,
+context switches will occur as often as possible (at every heap block
+allocation).  By default, context switches occur every 20ms
+milliseconds.  Note that GHC's internal timer ticks every 20ms, and
+the context switch timer is always a multiple of this timer, so 20ms
+is the maximum granularity available for timed context switches.
 </Para>
 </ListItem>
 </VarListEntry>