diff options
author | Jose Pedro Magalhaes <jpm@cs.uu.nl> | 2011-11-07 16:04:39 +0000 |
---|---|---|
committer | Jose Pedro Magalhaes <jpm@cs.uu.nl> | 2011-11-07 16:04:39 +0000 |
commit | 881b71a2ba39e94ccc3c273a06d39b9a941fa2ea (patch) | |
tree | aae624b9ad9e299c9a47c39a5b8a1590f0e3d344 | |
parent | 630b89551b14324fb1bfea853be700d8f32106c2 (diff) | |
download | haskell-881b71a2ba39e94ccc3c273a06d39b9a941fa2ea.tar.gz |
Improve user's guide doc for associated type defaults
Make it a separate section to help it stand out, and add an
example containing multiple defaults for a single type.
-rwxr-xr-x[-rw-r--r--] | docs/users_guide/glasgow_exts.xml | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index 1ea87ebd52..5123e1026c 100644..100755 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -4832,7 +4832,7 @@ type instance F t1 .. tn = t <sect2 id="assoc-decl"> -<title>Associated type families</title> +<title>Associated data and type families</title> <para> A data or type synonym family can be declared as part of a type class, thus: <programlisting> @@ -4909,9 +4909,13 @@ instance GMapKey Flob where the free indexed parameter is of a kind with a finite number of alternatives (unlike <literal>*</literal>). </para> + </sect3> + + <sect3 id="assoc-decl-defs"> + <title>Associated type synonym defaults</title> <para> - It is possible for the class defining the associated type to specify a default for - associated type instances. So for example, this is OK: + It is possible for the class defining the associated type to specify a + default for associated type instances. So for example, this is OK: <programlisting> class IsBoolMap v where type Key v @@ -4922,9 +4926,20 @@ class IsBoolMap v where instance IsBoolMap [(Int, Bool)] where lookupKey = lookup </programlisting> -A default declaration is not permitted for an associated <emphasis>data</emphasis> type. + +There can also be multiple defaults for a single type, as long as they do not +overlap: +<programlisting> +class C a where + type F a b + type F a Int = Bool + type F a Bool = Int +</programlisting> + +A default declaration is not permitted for an associated +<emphasis>data</emphasis> type. </para> - </sect3> + </sect3> <sect3 id="scoping-class-params"> <title>Scoping of class parameters</title> |