[commit: packages/base] master: Add instance Monad (WrappedMonad m) to Control.Applicative (#8218) (c831b4a)

git at git.haskell.org git at git.haskell.org
Mon Sep 23 17:56:58 CEST 2013


Repository : ssh://git@git.haskell.org/base

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c831b4acbff53754e7280d72970d77dd9532fe1d/base

>---------------------------------------------------------------

commit c831b4acbff53754e7280d72970d77dd9532fe1d
Author: Krzysztof Gogolewski <krz.gogolewski at gmail.com>
Date:   Mon Sep 23 17:56:07 2013 +0200

    Add instance Monad (WrappedMonad m) to Control.Applicative (#8218)


>---------------------------------------------------------------

c831b4acbff53754e7280d72970d77dd9532fe1d
 Control/Applicative.hs |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Control/Applicative.hs b/Control/Applicative.hs
index e1ad80a..78e2b4b 100644
--- a/Control/Applicative.hs
+++ b/Control/Applicative.hs
@@ -243,6 +243,11 @@ instance Monad m => Applicative (WrappedMonad m) where
     pure = WrapMonad . return
     WrapMonad f <*> WrapMonad v = WrapMonad (f `ap` v)
 
+-- Added in base-4.7.0.0 (GHC Trac #8218)
+instance Monad m => Monad (WrappedMonad m) where
+    return = WrapMonad . return
+    a >>= f = WrapMonad (unwrapMonad a >>= unwrapMonad . f)
+
 instance MonadPlus m => Alternative (WrappedMonad m) where
     empty = WrapMonad mzero
     WrapMonad u <|> WrapMonad v = WrapMonad (u `mplus` v)




More information about the ghc-commits mailing list