Fix documentation and merge fallout.
parent
ff03bb24bd
commit
1d1ca697af
|
@ -23,8 +23,9 @@ import Control.Monad.IO.Class
|
||||||
import Control.Monad.IO.Unlift
|
import Control.Monad.IO.Unlift
|
||||||
import Control.Monad.Trans.Class
|
import Control.Monad.Trans.Class
|
||||||
|
|
||||||
-- | Evaluate a 'Catch' effect, using 'MonadUnliftIO' to infer a correct
|
-- | Evaluate a 'Catch' effect, using 'MonadUnliftIO' to infer a correct unlifting function.
|
||||||
-- unlifting function.
|
--
|
||||||
|
-- | @since 1.0.0.0
|
||||||
runCatch :: MonadUnliftIO m => CatchC m a -> m a
|
runCatch :: MonadUnliftIO m => CatchC m a -> m a
|
||||||
runCatch = runCatchC
|
runCatch = runCatchC
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,6 @@ module Control.Effect.Catch
|
||||||
( Catch (..)
|
( Catch (..)
|
||||||
, catch
|
, catch
|
||||||
, catchSync
|
, catchSync
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
, runCatch
|
|
||||||
, CatchC (..)
|
|
||||||
>>>>>>> origin/master
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Carrier
|
import Control.Carrier
|
||||||
|
@ -28,6 +23,7 @@ import Control.Exception.Safe (isSyncException)
|
||||||
import Control.Monad.IO.Class
|
import Control.Monad.IO.Class
|
||||||
import Control.Monad.IO.Unlift
|
import Control.Monad.IO.Unlift
|
||||||
|
|
||||||
|
-- | @since 0.1.0.0
|
||||||
data Catch m k
|
data Catch m k
|
||||||
= forall output e . Exc.Exception e => CatchIO (m output) (e -> m output) (output -> m k)
|
= forall output e . Exc.Exception e => CatchIO (m output) (e -> m output) (output -> m k)
|
||||||
|
|
||||||
|
@ -40,19 +36,20 @@ instance Effect Catch where
|
||||||
handle state handler (CatchIO go cleanup k)
|
handle state handler (CatchIO go cleanup k)
|
||||||
= CatchIO (handler (go <$ state)) (\se -> handler (cleanup se <$ state)) (handler . fmap k)
|
= CatchIO (handler (go <$ state)) (\se -> handler (cleanup se <$ state)) (handler . fmap k)
|
||||||
|
|
||||||
-- | Like 'Control.Effect.Error.catchError', but delegating to
|
-- | Like 'Control.Effect.Error.catchError', but delegating to 'Control.Exception.catch' under the hood, which allows catching errors that might occur when lifting 'IO' computations.
|
||||||
-- 'Control.Exception.catch' under the hood, which allows catching
|
--
|
||||||
-- errors that might occur when lifting 'IO' computations.
|
-- Unhandled errors are rethrown. Use 'Exc.SomeException' if you want to catch all errors.
|
||||||
-- Unhandled errors are rethrown. Use 'Exc.SomeException' if you want
|
--
|
||||||
-- to catch all errors.
|
-- | @since 0.1.0.0
|
||||||
catch :: (Member Catch sig, Carrier sig m, Exc.Exception e)
|
catch :: (Member Catch sig, Carrier sig m, Exc.Exception e)
|
||||||
=> m a
|
=> m a
|
||||||
-> (e -> m a)
|
-> (e -> m a)
|
||||||
-> m a
|
-> m a
|
||||||
catch go cleanup = send (CatchIO go cleanup pure)
|
catch go cleanup = send (CatchIO go cleanup pure)
|
||||||
|
|
||||||
-- | Like 'catch', but the handler only engages on synchronous exceptions.
|
-- | Like 'catch', but the handler only engages on synchronous exceptions. Async exceptions are rethrown.
|
||||||
-- Async exceptions are rethrown.
|
--
|
||||||
|
-- | @since 0.1.0.0
|
||||||
catchSync :: (Member Catch sig, Carrier sig m, Exc.Exception e, MonadIO m)
|
catchSync :: (Member Catch sig, Carrier sig m, Exc.Exception e, MonadIO m)
|
||||||
=> m a
|
=> m a
|
||||||
-> (e -> m a)
|
-> (e -> m a)
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Control.Effect.Resource
|
||||||
|
|
||||||
import Control.Carrier
|
import Control.Carrier
|
||||||
|
|
||||||
-- | @since 0.1.0.0
|
-- | @since 1.0.0.0
|
||||||
data Resource m k
|
data Resource m k
|
||||||
= forall resource any output . Resource (m resource) (resource -> m any) (resource -> m output) (output -> m k)
|
= forall resource any output . Resource (m resource) (resource -> m any) (resource -> m output) (output -> m k)
|
||||||
| forall resource any output . OnError (m resource) (resource -> m any) (resource -> m output) (output -> m k)
|
| forall resource any output . OnError (m resource) (resource -> m any) (resource -> m output) (output -> m k)
|
||||||
|
@ -47,7 +47,7 @@ instance Effect Resource where
|
||||||
-- Carriers for 'bracket' must ensure that it is safe in the presence of
|
-- Carriers for 'bracket' must ensure that it is safe in the presence of
|
||||||
-- asynchronous exceptions.
|
-- asynchronous exceptions.
|
||||||
--
|
--
|
||||||
-- @since 0.1.0.0
|
-- @since 1.0.0.0
|
||||||
bracket :: Has Resource sig m
|
bracket :: Has Resource sig m
|
||||||
=> m resource -- ^ computation to run first ("acquire resource")
|
=> m resource -- ^ computation to run first ("acquire resource")
|
||||||
-> (resource -> m any) -- ^ computation to run last ("release resource")
|
-> (resource -> m any) -- ^ computation to run last ("release resource")
|
||||||
|
@ -58,7 +58,7 @@ bracket acquire release use = send (Resource acquire release use pure)
|
||||||
-- | Like 'bracket', but only performs the final action if there was an
|
-- | Like 'bracket', but only performs the final action if there was an
|
||||||
-- exception raised by the in-between computation.
|
-- exception raised by the in-between computation.
|
||||||
--
|
--
|
||||||
-- @since 0.2.0.0
|
-- @since 1.0.0.0
|
||||||
bracketOnError :: Has Resource sig m
|
bracketOnError :: Has Resource sig m
|
||||||
=> m resource -- ^ computation to run first ("acquire resource")
|
=> m resource -- ^ computation to run first ("acquire resource")
|
||||||
-> (resource -> m any) -- ^ computation to run last ("release resource")
|
-> (resource -> m any) -- ^ computation to run last ("release resource")
|
||||||
|
@ -68,7 +68,7 @@ bracketOnError acquire release use = send (OnError acquire release use pure)
|
||||||
|
|
||||||
-- | Like 'bracket', but for the simple case of one computation to run afterward.
|
-- | Like 'bracket', but for the simple case of one computation to run afterward.
|
||||||
--
|
--
|
||||||
-- @since 0.2.0.0
|
-- @since 1.0.0.0
|
||||||
finally :: Has Resource sig m
|
finally :: Has Resource sig m
|
||||||
=> m a -- ^ computation to run first
|
=> m a -- ^ computation to run first
|
||||||
-> m b -- ^ computation to run afterward (even if an exception was raised)
|
-> m b -- ^ computation to run afterward (even if an exception was raised)
|
||||||
|
@ -77,7 +77,7 @@ finally act end = bracket (pure ()) (const end) (const act)
|
||||||
|
|
||||||
-- | Like 'bracketOnError', but for the simple case of one computation to run afterward.
|
-- | Like 'bracketOnError', but for the simple case of one computation to run afterward.
|
||||||
--
|
--
|
||||||
-- @since 0.2.0.0
|
-- @since 1.0.0.0
|
||||||
onException :: Has Resource sig m
|
onException :: Has Resource sig m
|
||||||
=> m a -- ^ computation to run first
|
=> m a -- ^ computation to run first
|
||||||
-> m b -- ^ computation to run afterward if an exception was raised
|
-> m b -- ^ computation to run afterward if an exception was raised
|
||||||
|
|
Loading…
Reference in New Issue