[commit: packages/haskeline] master: Generalise constraints for InputT instances (7289f1f)
git at git.haskell.org
git at git.haskell.org
Sat Nov 28 17:42:58 UTC 2015
Repository : ssh://git@git.haskell.org/haskeline
On branch : master
Link : http://git.haskell.org/packages/haskeline.git/commitdiff/7289f1f65311f6072e7cb4321cf01e0fa81d3dae
>---------------------------------------------------------------
commit 7289f1f65311f6072e7cb4321cf01e0fa81d3dae
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Mon Nov 23 08:55:21 2015 +0100
Generalise constraints for InputT instances
I'm not sure why the code was written the way it was, but it seems we
can do better by letting GHC directly reuse `ReaderT`'s instances as
well as relaxing the constraints from
instance Monad m => Functor (InputT m)
instance Monad m => Applicative (InputT m)
instance Monad m => Monad (InputT m)
to
instance Functor m => Functor (InputT m)
instance Applicative m => Applicative (InputT m)
instance Monad m => Monad (InputT m)
This looks the same on GHC 7.8 (pre-AMP) as well as GHC 7.10 (post-AMP)
>---------------------------------------------------------------
7289f1f65311f6072e7cb4321cf01e0fa81d3dae
System/Console/Haskeline/InputT.hs | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/System/Console/Haskeline/InputT.hs b/System/Console/Haskeline/InputT.hs
index 383cf5f..c1ee55e 100644
--- a/System/Console/Haskeline/InputT.hs
+++ b/System/Console/Haskeline/InputT.hs
@@ -47,19 +47,12 @@ newtype InputT m a = InputT {unInputT ::
(ReaderT (IORef KillRing)
(ReaderT Prefs
(ReaderT (Settings m) m)))) a}
- deriving (Monad, MonadIO, MonadException)
+ deriving (Functor, Applicative, Monad, MonadIO, MonadException)
-- NOTE: we're explicitly *not* making InputT an instance of our
-- internal MonadState/MonadReader classes. Otherwise haddock
-- displays those instances to the user, and it makes it seem like
-- we implement the mtl versions of those classes.
-instance Monad m => Functor (InputT m) where
- fmap = liftM
-
-instance Monad m => Applicative (InputT m) where
- pure = return
- (<*>) = ap
-
instance MonadTrans InputT where
lift = InputT . lift . lift . lift . lift . lift
More information about the ghc-commits
mailing list