Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/4c353372c32276f179b96d6964a5c33c3211d295 >--------------------------------------------------------------- commit 4c353372c32276f179b96d6964a5c33c3211d295 Author: Max Bolingbroke <[email protected]> Date: Tue Sep 6 15:14:06 2011 +0100 Documentation for associated type instance defaults >--------------------------------------------------------------- docs/users_guide/glasgow_exts.xml | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index 1988f74..3e9f21b 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> _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
