[commit: ghc] master: Tidy up documentation of generalisation (3fc6ead)

Simon Peyton Jones simonpj at microsoft.com
Fri Apr 12 14:27:10 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/3fc6ead1027c2b0079e674173983dec875b55ca6

>---------------------------------------------------------------

commit 3fc6ead1027c2b0079e674173983dec875b55ca6
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Apr 12 12:22:39 2013 +0100

    Tidy up documentation of generalisation

>---------------------------------------------------------------

 docs/users_guide/glasgow_exts.xml | 40 +++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index c396237..d54cf40 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -7181,8 +7181,24 @@ scope over the methods defined in the <literal>where</literal> part.  For exampl
 
 </sect2>
 
+<sect2>
+<title>Bindings and generalisation</title>
+
+<sect3 id="monomorphism">
+<title>Switching off the dreaded Monomorphism Restriction</title>
+          <indexterm><primary><option>-XNoMonomorphismRestriction</option></primary></indexterm>
 
-<sect2 id="typing-binds">
+<para>Haskell's monomorphism restriction (see
+<ulink url="http://www.haskell.org/onlinereport/decls.html#sect4.5.5">Section
+4.5.5</ulink>
+of the Haskell Report)
+can be completely switched off by
+<option>-XNoMonomorphismRestriction</option>.
+</para>
+</sect3>
+
+
+<sect3 id="typing-binds">
 <title>Generalised typing of mutually recursive bindings</title>
 
 <para>
@@ -7243,23 +7259,9 @@ pattern binding must have the same context.  For example, this is fine:
   g y = (y &lt;= y) || f True
 </programlisting>
 </para>
-</sect2>
-
-<sect2 id="monomorphism">
-<title>Switching off the dreaded Monomorphism Restriction</title>
-          <indexterm><primary><option>-XNoMonomorphismRestriction</option></primary></indexterm>
-
-<para>Haskell's monomorphism restriction (see
-<ulink url="http://www.haskell.org/onlinereport/decls.html#sect4.5.5">Section
-4.5.5</ulink>
-of the Haskell Report)
-can be completely switched off by
-<option>-XNoMonomorphismRestriction</option>.
-</para>
-</sect2>
-
+</sect3>
 
-<sect2 id="mono-local-binds">
+<sect3 id="mono-local-binds">
 <title>Let-generalisation</title>
 <para>
 An ML-style language usually generalises the type of any let-bound or where-bound variable,
@@ -7288,11 +7290,13 @@ All of this applies only to bindings that lack an explicit type signature, so th
 infer its type.  If you supply a type signature, then that fixes type of the binding, end of story.
 </para><para>
 The rationale for this more conservative strategy is given in 
-<ulink url="http://research.microsoft.com/~simonpj/papers/constraints/index.htm">the papers</ulink> "Let should not be generalised" and "Modular type inference with local assumptions".
+<ulink url="http://research.microsoft.com/~simonpj/papers/constraints/index.htm">the papers</ulink> "Let should not be generalised" and "Modular type inference with local assumptions", and 
+a related <ulink url="http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7">blog post</ulink>.
 </para><para>
 The flag <option>-XMonoLocalBinds</option> is implied by <option>-XTypeFamilies</option> and <option>-XGADTs</option>.  You can switch it off again
 with <option>-XNoMonoLocalBinds</option> but type inference becomes less predicatable if you do so. (Read the papers!)
 </para>
+</sect3>
 </sect2>
 
 <sect2 id="type-holes">





More information about the ghc-commits mailing list