diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2012-06-07 07:28:27 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2012-06-07 07:28:27 +0100 |
commit | bb08287cd11ed9a94b31fd0081422c3d6143aed4 (patch) | |
tree | 7310eb83ff544bccb676ec3baef32b515d3aab85 /docs/users_guide | |
parent | cb705a38d677e2ab4cad37447c8180bd397d5576 (diff) | |
download | haskell-bb08287cd11ed9a94b31fd0081422c3d6143aed4.tar.gz |
Improve docs on FlexibleInstances/TypeSynonymInstances
Diffstat (limited to 'docs/users_guide')
-rw-r--r-- | 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 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> |