From 96479bd59462638081475cc91855be9ef0598fcd Mon Sep 17 00:00:00 2001 From: Luke Worth Date: Wed, 30 Aug 2023 10:23:49 +1000 Subject: [PATCH] refactor: remove do-notation --- src/Control/Monad/Error/Hoist.hs | 12 +++--------- src/Control/Monad/Fail/Hoist.hs | 12 +++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Control/Monad/Error/Hoist.hs b/src/Control/Monad/Error/Hoist.hs index fdb09d3..5204520 100644 --- a/src/Control/Monad/Error/Hoist.hs +++ b/src/Control/Monad/Error/Hoist.hs @@ -153,9 +153,7 @@ hoistErrorM => (e -> e') -> m (t a) -> m a -hoistErrorM e m = do - x <- m - hoistError e x +hoistErrorM e m = hoistError e =<< m -- | A version of 'hoistError'' that operates on values already in the monad. -- @@ -168,9 +166,7 @@ hoistErrorM' :: HoistError m t e e => m (t a) -> m a -hoistErrorM' m = do - x <- m - hoistError' x +hoistErrorM' m = hoistError' =<< m -- | A version of 'hoistErrorE' that operates on values already in the monad. hoistErrorEM @@ -251,9 +247,7 @@ infixl 8 => m (t a) -> e' -> m a -m e = do - x <- m - x e +m e = hoistError (const e) =<< m infixl 8 {-# INLINE () #-} diff --git a/src/Control/Monad/Fail/Hoist.hs b/src/Control/Monad/Fail/Hoist.hs index 8c7953f..266adba 100644 --- a/src/Control/Monad/Fail/Hoist.hs +++ b/src/Control/Monad/Fail/Hoist.hs @@ -117,9 +117,7 @@ hoistFailM => (e -> String) -> m (t a) -> m a -hoistFailM e m = do - x <- m - hoistFail e x +hoistFailM e m = hoistFail e =<< m -- | A version of 'hoistFail'' that operates on values already in the monad. -- @@ -132,9 +130,7 @@ hoistFailM' :: HoistFail m t String => m (t a) -> m a -hoistFailM' m = do - x <- m - hoistFail' x +hoistFailM' m = hoistFail' =<< m -- | A version of 'hoistFailE' that operates on values already in the monad. hoistFailEM @@ -213,9 +209,7 @@ infixl 8 <#> => m (t a) -> String -> m a -m e = do - x <- m - x <#> e +m e = hoistFail (const e) =<< m infixl 8 {-# INLINE () #-}