summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Bolingbroke <batterseapower@hotmail.com>2011-09-06 15:14:06 +0100
committerMax Bolingbroke <batterseapower@hotmail.com>2011-09-09 08:27:10 +0100
commit4c353372c32276f179b96d6964a5c33c3211d295 (patch)
tree4430bd7fd52086781cdb76f9d454217d3dfc7ca4
parentde8c8d68cabb5f24304fad2f03caa41fdf182b4f (diff)
downloadhaskell-4c353372c32276f179b96d6964a5c33c3211d295.tar.gz
Documentation for associated type instance defaults
-rw-r--r--docs/users_guide/glasgow_exts.xml16
1 files changed, 15 insertions, 1 deletions
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index 1988f74746..3e9f21b584 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -4878,7 +4878,21 @@ instance GMapKey Flob where
the free indexed parameter is of a kind with a finite number of alternatives
(unlike <literal>*</literal>).
</para>
- </sect3>
+ <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:
+<programlisting>
+class IsBoolMap v where
+ type Key v
+ type Key v = Int
+
+ lookupKey :: Key v -> v -> Maybe Bool
+
+instance IsBoolMap [(Int, Bool)] where
+ lookupKey = lookup
+</programlisting>
+ </para>
+ </sect3>
<sect3 id="scoping-class-params">
<title>Scoping of class parameters</title>