Safe Haskell | None |
---|---|
Language | Haskell2010 |
An effect that enables catching exceptions thrown from
impure computations such as IO
.
Use of the Error
effect from Control.Effect.Error
may lead to
simpler code, as well as avoiding the dynamically-typed nature of
Exception
. This is best used when integrating with third-party
libraries that operate in IO
. If you are using catch
for resource
management, consider using Resource
instead.
Synopsis
- data Catch m k = Exception e => CatchIO (m output) (e -> m output) (output -> k)
- catch :: (Member Catch sig, Carrier sig m, Exception e) => m a -> (e -> m a) -> m a
- catchSync :: (Member Catch sig, Carrier sig m, Exception e, MonadIO m) => m a -> (e -> m a) -> m a
- runCatch :: (forall x. m x -> IO x) -> CatchC m a -> m a
- newtype CatchC m a = CatchC {}
Documentation
catch :: (Member Catch sig, Carrier sig m, Exception e) => m a -> (e -> m a) -> m a Source #
Like catchError
, but delegating to
catch
under the hood, which allows catching
errors that might occur when lifting IO
computations.
Unhandled errors are rethrown. Use SomeException
if you want
to catch all errors.
catchSync :: (Member Catch sig, Carrier sig m, Exception e, MonadIO m) => m a -> (e -> m a) -> m a Source #
Like catch
, but the handler only engages on synchronous exceptions.
Async exceptions are rethrown.