diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-04-12 12:22:39 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-04-12 12:22:39 +0100 |
commit | 3fc6ead1027c2b0079e674173983dec875b55ca6 (patch) | |
tree | 3baa0dae24b7e1f3c02f28745ebfe235fee93cb2 /docs | |
parent | 37be6f06feed7351336bf8301fab93ac7c4d3a12 (diff) | |
download | haskell-3fc6ead1027c2b0079e674173983dec875b55ca6.tar.gz |
Tidy up documentation of generalisation
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/glasgow_exts.xml | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index c396237f27..d54cf40d92 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 <= 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"> |