Skip to content

Commit

Permalink
refactor: remove do-notation
Browse files Browse the repository at this point in the history
  • Loading branch information
lrworth committed Aug 30, 2023
1 parent 6d526b2 commit 96479bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
12 changes: 3 additions & 9 deletions src/Control/Monad/Error/Hoist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
--
Expand All @@ -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
Expand Down Expand Up @@ -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 (<!?>) #-}
12 changes: 3 additions & 9 deletions src/Control/Monad/Fail/Hoist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
--
Expand All @@ -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
Expand Down Expand Up @@ -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 (<!#>) #-}

0 comments on commit 96479bd

Please sign in to comment.