async-io-either 0.1.0.3 → 0.1.0.4
raw patch · 2 files changed
+20/−2 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
async-io-either.cabal view
@@ -1,5 +1,5 @@ name: async-io-either-version: 0.1.0.3+version: 0.1.0.4 synopsis: Could be useful description: A way of running any IO type and capturing any exception, maybe, I think... homepage: https://github.com/mankyKitty/async-io-either#readme
src/Control/Concurrent/Async/Either.hs view
@@ -1,7 +1,7 @@ --------------------------- -- | -- These functions are partially inspired by the 'Catching All Exceptions' blog <https://www.schoolofhaskell.com/user/snoyberg/general-haskell/exceptions/catching-all-exceptions post>--- that explains a useful way of pushing off a (IO a) of a risky or smelly nature, and having it+-- that explains a useful way of pushing off a @IO a@ of a risky or smelly nature, and having it -- provide a value indicating success or failure. This library does not go any further than taking -- this result to a value, be it an exception or the desired result. You get an either, that's it. --@@ -39,6 +39,10 @@ import Control.Retry (RetryPolicyM, RetryStatus, recoverAll) +-- |+-- Leverage the <http://hackage.haskell.org/package/retry retry> package to run your action+-- in a separate thread with a specific plan for retrying failures, yet capturing any exceptions+-- and returning the final result. handleRetryE :: MonadIO m => RetryPolicyM IO@@ -47,6 +51,9 @@ handleRetryE rPolicy f = runAsyncForE ( recoverAll rPolicy f ) +-- |+-- As per @handleRetryE@ but allows you to annotate or extract different error information from+-- the @SomeException@. handleRetryToE :: MonadIO m => RetryPolicyM IO@@ -56,6 +63,13 @@ handleRetryToE rPolicy f eFn = runAsyncToE ( recoverAll rPolicy f ) eFn +-- |+-- The workhorse of this package, executes the @IO a@ in a separate thread+-- using @STM@. It should catch any and all exceptions in the process, even asynchronous ones!!+-- The result is a nice friendly @Either@ that you can then use however you desire. Instead of+-- things lurking around to break your nice Haskell code when you least expect it, BECAUSE IT WASN'T IN THE TYPE.+--+-- *mumble mumble* runAsyncForE :: MonadIO m => IO a@@ -63,6 +77,10 @@ runAsyncForE = liftIO . flip Async.withAsync Async.waitCatch +-- |+-- As per @runAsyncForE@ except you can attempt to turn the @SomeException@ into an Error type of your own.+-- Useful if there are instance of @Exception@ that you would like to annotate differently, or you have an+-- error type of your own that provides more context regarding what was going on at the time of the fire. runAsyncToE :: MonadIO m => IO a