[commit: packages/haskeline] master: Canonicalise AMP instances (b366b10)

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


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

On branch  : master
Link       : http://git.haskell.org/packages/haskeline.git/commitdiff/b366b10867c351097ce94b58c3bc637f41acc5e1

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

commit b366b10867c351097ce94b58c3bc637f41acc5e1
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Mon Nov 23 09:03:52 2015 +0100

    Canonicalise AMP instances
    
    This flips the AMP instance definitions into canonical form and makes
    the code a bit more future proof.


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

b366b10867c351097ce94b58c3bc637f41acc5e1
 System/Console/Haskeline/Command.hs | 4 ++--
 System/Console/Haskeline/Monads.hs  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/System/Console/Haskeline/Command.hs b/System/Console/Haskeline/Command.hs
index 986fd42..1a0d915 100644
--- a/System/Console/Haskeline/Command.hs
+++ b/System/Console/Haskeline/Command.hs
@@ -66,11 +66,11 @@ instance Monad m => Functor (CmdM m) where
     fmap = liftM
 
 instance Monad m => Applicative (CmdM m) where
-    pure  = return
+    pure  = Result
     (<*>) = ap
 
 instance Monad m => Monad (CmdM m) where
-    return = Result
+    return = pure
 
     GetKey km >>= g = GetKey $ fmap (>>= g) km
     DoEffect e f >>= g = DoEffect e (f >>= g)
diff --git a/System/Console/Haskeline/Monads.hs b/System/Console/Haskeline/Monads.hs
index 6668e96..d5fc1bb 100644
--- a/System/Console/Haskeline/Monads.hs
+++ b/System/Console/Haskeline/Monads.hs
@@ -77,11 +77,11 @@ instance Monad m => Functor (StateT s m) where
     fmap  = liftM
 
 instance Monad m => Applicative (StateT s m) where
-    pure  = return
+    pure x = StateT $ \s -> return $ \f -> f x s
     (<*>) = ap
 
 instance Monad m => Monad (StateT s m) where
-    return x = StateT $ \s -> return $ \f -> f x s
+    return = pure
     StateT f >>= g = StateT $ \s -> do
         useX <- f s
         useX $ \x s' -> getStateTFunc (g x) s'



More information about the ghc-commits mailing list