diff options
author | Micha Wiedenmann <mw-r1@posteo.de> | 2019-09-23 05:07:49 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-12-10 19:52:44 -0500 |
commit | e3bba7e4b221139090edf54a18c7e0e1ec3f9be8 (patch) | |
tree | ce064abd2796d83b14a0807cb68c48efb245b462 /docs | |
parent | d46a72e19e1b508358827e7270139f3273915697 (diff) | |
download | haskell-e3bba7e4b221139090edf54a18c7e0e1ec3f9be8.tar.gz |
users guide: Motivation of DefaultSignatures
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/glasgow_exts.rst | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/docs/users_guide/glasgow_exts.rst b/docs/users_guide/glasgow_exts.rst index 7ba170845a..5034d012a1 100644 --- a/docs/users_guide/glasgow_exts.rst +++ b/docs/users_guide/glasgow_exts.rst @@ -6139,11 +6139,14 @@ a class: :: enum = [] The type of the ``enum`` method is ``[a]``, and this is also the type of -the default method. You can lift this restriction and give another type -to the default method using the extension :extension:`DefaultSignatures`. For -instance, if you have written a generic implementation of enumeration in -a class ``GEnum`` with method ``genum`` in terms of ``GHC.Generics``, -you can specify a default method that uses that generic implementation: :: +the default method. You can change the type of the default method by +requiring a different context using the extension +:extension:`DefaultSignatures`. For instance, if you have written a +generic implementation of enumeration in a class ``GEnum`` with method +``genum``, you can specify a default method that uses that generic +implementation. But your default implementation can only be used if the +constraints are satisfied, therefore you need to change the type of the +default method :: class Enum a where enum :: [a] |