[commit: ghc] master: Improve docs on FlexibleInstances/TypeSynonymInstances (bb08287)

Simon Peyton Jones simonpj at microsoft.com
Thu Jun 7 15:09:19 CEST 2012


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/bb08287cd11ed9a94b31fd0081422c3d6143aed4

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

commit bb08287cd11ed9a94b31fd0081422c3d6143aed4
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Jun 7 07:28:27 2012 +0100

    Improve docs on FlexibleInstances/TypeSynonymInstances

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

 docs/users_guide/glasgow_exts.xml |   47 +++++++++++++++----------------------
 1 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 14d0630..6681448 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -3962,46 +3962,37 @@ must be of the form <literal>C (T a1 ... an)</literal>, where
 and the <literal>a1 ... an</literal> are distinct type variables.
 GHC relaxes these rules in two ways.
 <itemizedlist>
-<listitem>
-<para>
-The <option>-XFlexibleInstances</option> flag allows the head of the instance
-declaration to mention arbitrary nested types.
-For example, this becomes a legal instance declaration
-<programlisting>
-  instance C (Maybe Int) where ...
-</programlisting>
-See also the <link linkend="instance-overlap">rules on overlap</link>.
-</para></listitem>
 <listitem><para>
 With the <option>-XTypeSynonymInstances</option> flag, instance heads may use type
 synonyms. As always, using a type synonym is just shorthand for
 writing the RHS of the type synonym definition.  For example:
-
-
 <programlisting>
-  type Point = (Int,Int)
-  instance C Point   where ...
-  instance C [Point] where ...
+  type Point a = (a,a)
+  instance C (Point a)   where ...
 </programlisting>
-
-
-is legal.  However, if you added
-
-
+is legal.  The instance declaration is equivalent to
 <programlisting>
-  instance C (Int,Int) where ...
+  instance C (a,a) where ...
 </programlisting>
-
-
-as well, then the compiler will complain about the overlapping
-(actually, identical) instance declarations.  As always, type synonyms
+As always, type synonyms
 must be fully applied.  You cannot, for example, write:
-
 <programlisting>
-  type P a = [[a]]
-  instance Monad P where ...
+  instance Monad Point where ...
 </programlisting>
+</para></listitem>
 
+<listitem>
+<para>
+The <option>-XFlexibleInstances</option> flag allows the head of the instance
+declaration to mention arbitrary nested types.
+For example, this becomes a legal instance declaration
+<programlisting>
+  instance C (Maybe Int) where ...
+</programlisting>
+See also the <link linkend="instance-overlap">rules on overlap</link>.
+</para>
+<para>
+The <option>-XFlexibleInstances</option> flag implies <option>-XTypeSynonymInstances</option>.
 </para></listitem>
 </itemizedlist>
 </para>





More information about the Cvs-ghc mailing list