Add attempt
no-longer-on-githu-b opened this issue · 2 comments
no-longer-on-githu-b commented
I find this function very useful:
attempt :: forall m e a. MonadError e m => m a -> m (Either e a)
attempt a = (Right <$> a) `catchError` (pure <<< Left)This makes it easier to "not catch more than you need". For example when you want to catch only exceptions thrown by a, and not by b, there is no reasonable way to do this without attempt:
attempt a >>= either e b
-- vs overly defensive
(a >>= b) `catchError` epaf31 commented
This is the same as try from Control.Monad.Exception so I think we should call this try as well.
rightfold commented
👍🏻
Sent from my iPhone.
… Op 6 apr. 2017 om 17:26 heeft Phil Freeman ***@***.***> het volgende geschreven:
This is the same as try from Control.Monad.Exception so I think we should call this try as well.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.