-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Please see README.md
@package safe-exceptions
@version 0.1.7.4


-- | Please see the README.md file in the safe-exceptions repo for
--   information on how to use this module. Relevant links:
--   
--   <ul>
--   <li><a>https://github.com/fpco/safe-exceptions#readme</a></li>
--   <li><a>https://www.stackage.org/package/safe-exceptions</a></li>
--   </ul>
module Control.Exception.Safe

-- | Synchronously throw the given exception
throw :: (HasCallStack, MonadThrow m, Exception e) => e -> m a

-- | Synonym for <a>throw</a>
throwIO :: (HasCallStack, MonadThrow m, Exception e) => e -> m a

-- | Synonym for <a>throw</a>
throwM :: (HasCallStack, MonadThrow m, Exception e) => e -> m a

-- | A convenience function for throwing a user error. This is useful for
--   cases where it would be too high a burden to define your own exception
--   type.
--   
--   This throws an exception of type <a>StringException</a>. When GHC
--   supports it (base 4.9 and GHC 8.0 and onward), it includes a call
--   stack.
throwString :: (MonadThrow m, HasCallStack) => String -> m a

-- | Exception type thrown by <a>throwString</a>.
--   
--   Note that the second field of the data constructor depends on GHC/base
--   version. For base 4.9 and GHC 8.0 and later, the second field is a
--   call stack. Previous versions of GHC and base do not support call
--   stacks, and the field is simply unit (provided to make pattern
--   matching across GHC versions easier).
data StringException
StringException :: String -> CallStack -> StringException

-- | Throw an asynchronous exception to another thread.
--   
--   Synchronously typed exceptions will be wrapped into an
--   <a>AsyncExceptionWrapper</a>, see
--   <a>https://github.com/fpco/safe-exceptions#determining-sync-vs-async</a>
--   
--   It's usually a better idea to use the async package, see
--   <a>https://github.com/fpco/safe-exceptions#quickstart</a>
throwTo :: (Exception e, MonadIO m) => ThreadId -> e -> m ()

-- | Generate a pure value which, when forced, will synchronously throw the
--   given exception
--   
--   Generally it's better to avoid using this function and instead use
--   <a>throw</a>, see
--   <a>https://github.com/fpco/safe-exceptions#quickstart</a>
impureThrow :: (HasCallStack, Exception e) => e -> a

-- | Same as upstream <a>catch</a>, but will not catch asynchronous
--   exceptions
catch :: (HasCallStack, MonadCatch m, Exception e) => m a -> (e -> m a) -> m a

-- | <a>catch</a> specialized to only catching <a>IOException</a>s
catchIO :: (HasCallStack, MonadCatch m) => m a -> (IOException -> m a) -> m a

-- | <a>catch</a> specialized to catch all synchronous exception
catchAny :: (HasCallStack, MonadCatch m) => m a -> (SomeException -> m a) -> m a

-- | Same as <a>catch</a>, but fully force evaluation of the result value
--   to find all impure exceptions.
catchDeep :: (HasCallStack, MonadCatch m, MonadIO m, Exception e, NFData a) => m a -> (e -> m a) -> m a

-- | <a>catchDeep</a> specialized to catch all synchronous exception
catchAnyDeep :: (HasCallStack, MonadCatch m, MonadIO m, NFData a) => m a -> (SomeException -> m a) -> m a

-- | <a>catch</a> without async exception safety
--   
--   Generally it's better to avoid using this function since we do not
--   want to recover from async exceptions, see
--   <a>https://github.com/fpco/safe-exceptions#quickstart</a>
catchAsync :: (HasCallStack, MonadCatch m, Exception e) => m a -> (e -> m a) -> m a

-- | <a>catchJust</a> is like <a>catch</a> but it takes an extra argument
--   which is an exception predicate, a function which selects which type
--   of exceptions we're interested in.
catchJust :: (HasCallStack, MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a

-- | Flipped version of <a>catch</a>
handle :: (HasCallStack, MonadCatch m, Exception e) => (e -> m a) -> m a -> m a

-- | <a>handle</a> specialized to only catching <a>IOException</a>s
handleIO :: (HasCallStack, MonadCatch m) => (IOException -> m a) -> m a -> m a

-- | Flipped version of <a>catchAny</a>
handleAny :: (HasCallStack, MonadCatch m) => (SomeException -> m a) -> m a -> m a

-- | Flipped version of <a>catchDeep</a>
handleDeep :: (HasCallStack, MonadCatch m, Exception e, MonadIO m, NFData a) => (e -> m a) -> m a -> m a

-- | Flipped version of <a>catchAnyDeep</a>
handleAnyDeep :: (HasCallStack, MonadCatch m, MonadIO m, NFData a) => (SomeException -> m a) -> m a -> m a

-- | Flipped version of <a>catchAsync</a>
--   
--   Generally it's better to avoid using this function since we do not
--   want to recover from async exceptions, see
--   <a>https://github.com/fpco/safe-exceptions#quickstart</a>
handleAsync :: (HasCallStack, MonadCatch m, Exception e) => (e -> m a) -> m a -> m a

-- | Flipped <a>catchJust</a>.
handleJust :: (HasCallStack, MonadCatch m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a

-- | Same as upstream <a>try</a>, but will not catch asynchronous
--   exceptions
try :: (HasCallStack, MonadCatch m, Exception e) => m a -> m (Either e a)

-- | <a>try</a> specialized to only catching <a>IOException</a>s
tryIO :: (HasCallStack, MonadCatch m) => m a -> m (Either IOException a)

-- | <a>try</a> specialized to catch all synchronous exceptions
tryAny :: (HasCallStack, MonadCatch m) => m a -> m (Either SomeException a)

-- | Same as <a>try</a>, but fully force evaluation of the result value to
--   find all impure exceptions.
tryDeep :: (HasCallStack, MonadCatch m, MonadIO m, Exception e, NFData a) => m a -> m (Either e a)

-- | <a>tryDeep</a> specialized to catch all synchronous exceptions
tryAnyDeep :: (HasCallStack, MonadCatch m, MonadIO m, NFData a) => m a -> m (Either SomeException a)

-- | <a>try</a> without async exception safety
--   
--   Generally it's better to avoid using this function since we do not
--   want to recover from async exceptions, see
--   <a>https://github.com/fpco/safe-exceptions#quickstart</a>
tryAsync :: (HasCallStack, MonadCatch m, Exception e) => m a -> m (Either e a)

-- | A variant of <a>try</a> that takes an exception predicate to select
--   which exceptions are caught.
tryJust :: (HasCallStack, MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)
data Handler (m :: Type -> Type) a
Handler :: (e -> m a) -> Handler (m :: Type -> Type) a

-- | Same as upstream <a>catches</a>, but will not catch asynchronous
--   exceptions
catches :: (HasCallStack, MonadCatch m, MonadThrow m) => m a -> [Handler m a] -> m a

-- | Same as <a>catches</a>, but fully force evaluation of the result value
--   to find all impure exceptions.
catchesDeep :: (HasCallStack, MonadCatch m, MonadThrow m, MonadIO m, NFData a) => m a -> [Handler m a] -> m a

-- | <a>catches</a> without async exception safety
--   
--   Generally it's better to avoid using this function since we do not
--   want to recover from async exceptions, see
--   <a>https://github.com/fpco/safe-exceptions#quickstart</a>
catchesAsync :: (HasCallStack, MonadCatch m, MonadThrow m) => m a -> [Handler m a] -> m a

-- | Async safe version of <a>onException</a>
onException :: (HasCallStack, MonadMask m) => m a -> m b -> m a

-- | Async safe version of <a>bracket</a>
bracket :: (HasCallStack, MonadMask m) => m a -> (a -> m b) -> (a -> m c) -> m c

-- | Async safe version of <a>bracket_</a>
bracket_ :: (HasCallStack, MonadMask m) => m a -> m b -> m c -> m c

-- | Async safe version of <a>finally</a>
finally :: (HasCallStack, MonadMask m) => m a -> m b -> m a

-- | Like <a>onException</a>, but provides the handler the thrown
--   exception.
withException :: (HasCallStack, MonadMask m, Exception e) => m a -> (e -> m b) -> m a

-- | Async safe version of <a>bracketOnError</a>
bracketOnError :: (HasCallStack, MonadMask m) => m a -> (a -> m b) -> (a -> m c) -> m c

-- | A variant of <a>bracketOnError</a> where the return value from the
--   first computation is not required.
bracketOnError_ :: (HasCallStack, MonadMask m) => m a -> m b -> m c -> m c

-- | Async safe version of <a>bracket</a> with access to the exception in
--   the cleanup action.
bracketWithError :: (HasCallStack, MonadMask m) => m a -> (Maybe SomeException -> a -> m b) -> (a -> m c) -> m c

-- | Wrap up an asynchronous exception to be treated as a synchronous
--   exception
--   
--   This is intended to be created via <a>toSyncException</a>
data SyncExceptionWrapper
SyncExceptionWrapper :: e -> SyncExceptionWrapper

-- | Convert an exception into a synchronous exception
--   
--   For synchronous exceptions, this is the same as <a>toException</a>.
--   For asynchronous exceptions, this will wrap up the exception with
--   <a>SyncExceptionWrapper</a>
toSyncException :: Exception e => e -> SomeException

-- | Wrap up a synchronous exception to be treated as an asynchronous
--   exception
--   
--   This is intended to be created via <a>toAsyncException</a>
data AsyncExceptionWrapper
AsyncExceptionWrapper :: e -> AsyncExceptionWrapper

-- | Convert an exception into an asynchronous exception
--   
--   For asynchronous exceptions, this is the same as <a>toException</a>.
--   For synchronous exceptions, this will wrap up the exception with
--   <a>AsyncExceptionWrapper</a>
toAsyncException :: Exception e => e -> SomeException

-- | Check if the given exception is synchronous
isSyncException :: Exception e => e -> Bool

-- | Check if the given exception is asynchronous
isAsyncException :: Exception e => e -> Bool
class Monad m => MonadThrow (m :: Type -> Type)
class MonadThrow m => MonadCatch (m :: Type -> Type)
class MonadCatch m => MonadMask (m :: Type -> Type)
mask :: (MonadMask m, HasCallStack) => ((forall a. () => m a -> m a) -> m b) -> m b
uninterruptibleMask :: (MonadMask m, HasCallStack) => ((forall a. () => m a -> m a) -> m b) -> m b
generalBracket :: (MonadMask m, HasCallStack) => m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
mask_ :: (HasCallStack, MonadMask m) => m a -> m a
uninterruptibleMask_ :: (HasCallStack, MonadMask m) => m a -> m a
catchIOError :: (HasCallStack, MonadCatch m) => m a -> (IOError -> m a) -> m a
handleIOError :: (HasCallStack, MonadCatch m) => (IOError -> m a) -> m a -> m a
class (Typeable e, Show e) => Exception e
toException :: Exception e => e -> SomeException
fromException :: Exception e => SomeException -> Maybe e
displayException :: Exception e => e -> String
backtraceDesired :: Exception e => e -> Bool
class Typeable (a :: k)
data SomeException
SomeException :: e -> SomeException
data SomeAsyncException
SomeAsyncException :: e -> SomeAsyncException
data IOException
assert :: Bool -> a -> a
instance GHC.Internal.Exception.Type.Exception Control.Exception.Safe.AsyncExceptionWrapper
instance GHC.Internal.Exception.Type.Exception Control.Exception.Safe.StringException
instance GHC.Internal.Exception.Type.Exception Control.Exception.Safe.SyncExceptionWrapper
instance GHC.Internal.Show.Show Control.Exception.Safe.AsyncExceptionWrapper
instance GHC.Internal.Show.Show Control.Exception.Safe.StringException
instance GHC.Internal.Show.Show Control.Exception.Safe.SyncExceptionWrapper
