From e39fcfea588204af118bd448062312abd26cc40d Mon Sep 17 00:00:00 2001 From: Yui Nishizawa Date: Sat, 29 Aug 2026 17:09:44 +0900 Subject: [PATCH] [Refactor] Remove superfluous lazy pattern match in StateT --- Control/Monad/Trans/State/Lazy.hs | 8 ++++---- Control/Monad/Trans/State/Strict.hs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Control/Monad/Trans/State/Lazy.hs b/Control/Monad/Trans/State/Lazy.hs index 4534027..8f89e70 100644 --- a/Control/Monad/Trans/State/Lazy.hs +++ b/Control/Monad/Trans/State/Lazy.hs @@ -166,17 +166,17 @@ newtype StateT s m a = StateT { runStateT :: s -> m (a,s) } -- | Evaluate a state computation with the given initial state -- and return the final value, discarding the final state. -- --- * @'evalStateT' m s = 'liftM' 'fst' ('runStateT' m s)@ +-- * @'evalStateT' m s = 'fmap 'fst' ('runStateT' m s)@ evalStateT :: Functor m => StateT s m a -> s -> m a -evalStateT m s = (\(~(a, _)) -> a) <$> runStateT m s +evalStateT m s = (\(a, _) -> a) <$> runStateT m s {-# INLINE evalStateT #-} -- | Evaluate a state computation with the given initial state -- and return the final state, discarding the final value. -- --- * @'execStateT' m s = 'liftM' 'snd' ('runStateT' m s)@ +-- * @'execStateT' m s = 'fmap 'snd' ('runStateT' m s)@ execStateT :: Functor m => StateT s m a -> s -> m s -execStateT m s = (\(~(_, s')) -> s') <$> runStateT m s +execStateT m s = (\(_, s') -> s') <$> runStateT m s {-# INLINE execStateT #-} -- | Map both the return value and final state of a computation using diff --git a/Control/Monad/Trans/State/Strict.hs b/Control/Monad/Trans/State/Strict.hs index 92442ac..a3752fc 100644 --- a/Control/Monad/Trans/State/Strict.hs +++ b/Control/Monad/Trans/State/Strict.hs @@ -159,7 +159,7 @@ newtype StateT s m a = StateT { runStateT :: s -> m (a,s) } -- | Evaluate a state computation with the given initial state -- and return the final value, discarding the final state. -- --- * @'evalStateT' m s = 'liftM' 'fst' ('runStateT' m s)@ +-- * @'evalStateT' m s = 'fmap 'fst' ('runStateT' m s)@ evalStateT :: Functor m => StateT s m a -> s -> m a evalStateT m s = (\(a, _) -> a) <$> runStateT m s {-# INLINE evalStateT #-} @@ -167,7 +167,7 @@ evalStateT m s = (\(a, _) -> a) <$> runStateT m s -- | Evaluate a state computation with the given initial state -- and return the final state, discarding the final value. -- --- * @'execStateT' m s = 'liftM' 'snd' ('runStateT' m s)@ +-- * @'execStateT' m s = 'fmap 'snd' ('runStateT' m s)@ execStateT :: Functor m => StateT s m a -> s -> m s execStateT m s = (\(_, s') -> s') <$> runStateT m s {-# INLINE execStateT #-}