[commit: packages/terminfo] master: Canonicalise Monad instance (632c4bf)

git at git.haskell.org git at git.haskell.org
Sat Nov 28 17:43:16 UTC 2015


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

On branch  : master
Link       : http://git.haskell.org/packages/terminfo.git/commitdiff/632c4bf0d7390b44ea818b7530bed1869da27788

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

commit 632c4bf0d7390b44ea818b7530bed1869da27788
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Mon Nov 23 09:25:29 2015 +0100

    Canonicalise Monad instance
    
    This refactors the Monad instance of `Capability` into the recommended
    canonical form and makes the code a bit more future proof.


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

632c4bf0d7390b44ea818b7530bed1869da27788
 System/Console/Terminfo/Base.hs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/System/Console/Terminfo/Base.hs b/System/Console/Terminfo/Base.hs
index 87ac774..1f60679 100644
--- a/System/Console/Terminfo/Base.hs
+++ b/System/Console/Terminfo/Base.hs
@@ -198,11 +198,11 @@ instance Functor Capability where
     fmap f (Capability g) = Capability $ \t -> fmap (fmap f) (g t)
 
 instance Applicative Capability where
-    pure  = return
+    pure = Capability . const . pure . Just
     (<*>) = ap
 
 instance Monad Capability where
-    return = Capability . const . return . Just
+    return = pure
     Capability f >>= g = Capability $ \t -> do
         mx <- f t
         case mx of



More information about the ghc-commits mailing list