summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Ivanov <ethercrow@gmail.com>2017-02-23 11:50:27 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-23 11:50:33 -0500
commit4a8e9b0bf2c48f1a9b8c8afd2c9b781da5fc866a (patch)
tree415f7ecdbb69667f536fd39b15ee1eabafa8c329
parentc6406fa3638bb95fa9de4b0f3b3cc98f56a82b55 (diff)
downloadhaskell-wip/inline-ioenv.tar.gz
Inline IOEnv methodswip/inline-ioenv
These changes seem to make compiler allocate less and a bit faster. However, I've checked only with a few files and only with a profiled build of stage2. How do I check the alleged performance improvement properly? Reviewers: austin, bgamari, dfeuer Subscribers: dfeuer, thomie Differential Revision: https://phabricator.haskell.org/D3171
-rw-r--r--compiler/utils/IOEnv.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/utils/IOEnv.hs b/compiler/utils/IOEnv.hs
index 29854c51fe..17af162c9f 100644
--- a/compiler/utils/IOEnv.hs
+++ b/compiler/utils/IOEnv.hs
@@ -58,7 +58,9 @@ unIOEnv :: IOEnv env a -> (env -> IO a)
unIOEnv (IOEnv m) = m
instance Monad (IOEnv m) where
+ {-# INLINE (>>=) #-}
(>>=) = thenM
+ {-# INLINE (>>) #-}
(>>) = (*>)
fail _ = failM -- Ignore the string
@@ -70,19 +72,24 @@ instance MonadFail.MonadFail (IOEnv m) where
instance Applicative (IOEnv m) where
pure = returnM
+ {-# INLINE (<*>) #-}
IOEnv f <*> IOEnv x = IOEnv (\ env -> f env <*> x env )
(*>) = thenM_
instance Functor (IOEnv m) where
+ {-# INLINE fmap #-}
fmap f (IOEnv m) = IOEnv (\ env -> fmap f (m env))
+{-# INLINE returnM #-}
returnM :: a -> IOEnv env a
returnM a = IOEnv (\ _ -> return a)
+{-# INLINE thenM #-}
thenM :: IOEnv env a -> (a -> IOEnv env b) -> IOEnv env b
thenM (IOEnv m) f = IOEnv (\ env -> do { r <- m env ;
unIOEnv (f r) env })
+{-# INLINE thenM_ #-}
thenM_ :: IOEnv env a -> IOEnv env b -> IOEnv env b
thenM_ (IOEnv m) f = IOEnv (\ env -> do { _ <- m env ; unIOEnv f env })