diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2013-10-05 15:40:28 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2013-10-05 15:42:39 +0200 |
commit | a333f7bc77432bdd1af7f34968227196a2f3487d (patch) | |
tree | a38814d1a2ff938917836d4e1ce1655b03b61294 /libraries/base/Control | |
parent | add3bae60662122d0d64a3d5b05396081e91a1fc (diff) | |
download | haskell-a333f7bc77432bdd1af7f34968227196a2f3487d.tar.gz |
Add `instance Monoid a => Monoid (Const a b)`
For more details, see original proposal at
http://permalink.gmane.org/gmane.comp.lang.haskell.libraries/20369
Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Diffstat (limited to 'libraries/base/Control')
-rw-r--r-- | libraries/base/Control/Applicative.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libraries/base/Control/Applicative.hs b/libraries/base/Control/Applicative.hs index 78e2b4b145..dbfa27268a 100644 --- a/libraries/base/Control/Applicative.hs +++ b/libraries/base/Control/Applicative.hs @@ -230,6 +230,11 @@ newtype Const a b = Const { getConst :: a } instance Functor (Const m) where fmap _ (Const v) = Const v +-- Added in base-4.7.0.0 +instance Monoid a => Monoid (Const a b) where + mempty = Const mempty + mappend (Const a) (Const b) = Const (mappend a b) + instance Monoid m => Applicative (Const m) where pure _ = Const mempty Const f <*> Const v = Const (f `mappend` v) |