summaryrefslogtreecommitdiff
path: root/docs/users_guide
diff options
context:
space:
mode:
Diffstat (limited to 'docs/users_guide')
-rw-r--r--docs/users_guide/glasgow_exts.xml47
1 files changed, 19 insertions, 28 deletions
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 14d0630145..6681448c2c 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>