Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- throwM :: forall e m a. (Exception e, MonadIO m, HasCallStack) => e -> m a
- throwString :: forall m a. (MonadIO m, HasCallStack) => String -> m a
- fromJustNoteM :: forall m a. (MonadIO m, HasCallStack) => String -> Maybe a -> m a
- impossible :: forall m a. (MonadIO m, HasCallStack) => m a
- catch :: forall e m a. (Exception e, MonadUnliftIO m, HasCallStack) => m a -> (e -> m a) -> m a
- catchJust :: forall e b m a. (Exception e, MonadUnliftIO m, HasCallStack) => (e -> Maybe b) -> m a -> (b -> m a) -> m a
- catches :: forall m a. (MonadUnliftIO m, HasCallStack) => m a -> [ExceptionHandler m a] -> m a
- try :: forall e m a. (Exception e, MonadUnliftIO m, HasCallStack) => m a -> m (Either e a)
- tryJust :: forall e b m a. (Exception e, MonadUnliftIO m, HasCallStack) => (e -> Maybe b) -> m a -> m (Either b a)
- withException :: forall e a m b. (Exception e, MonadUnliftIO m, HasCallStack) => m a -> (e -> m b) -> m a
- checkpoint :: (MonadUnliftIO m, HasCallStack) => Annotation -> m a -> m a
- checkpointMany :: (MonadUnliftIO m, HasCallStack) => [Annotation] -> m a -> m a
- checkpointCallStack :: forall m a. (MonadUnliftIO m, HasCallStack) => m a -> m a
- data IO a
- class Monad m => MonadIO (m :: Type -> Type)
- class MonadIO m => MonadUnliftIO (m :: Type -> Type)
- module Freckle.App.Exception.Types
Documentation
throwString :: forall m a. (MonadIO m, HasCallStack) => String -> m a Source #
fromJustNoteM :: forall m a. (MonadIO m, HasCallStack) => String -> Maybe a -> m a Source #
impossible :: forall m a. (MonadIO m, HasCallStack) => m a Source #
catch :: forall e m a. (Exception e, MonadUnliftIO m, HasCallStack) => m a -> (e -> m a) -> m a Source #
catchJust :: forall e b m a. (Exception e, MonadUnliftIO m, HasCallStack) => (e -> Maybe b) -> m a -> (b -> m a) -> m a Source #
:: forall m a. (MonadUnliftIO m, HasCallStack) | |
=> m a | Action to run |
-> [ExceptionHandler m a] | Recovery actions to run if the first action throws an exception
with a type of either |
-> m a |
:: forall e m a. (Exception e, MonadUnliftIO m, HasCallStack) | |
=> m a | Action to run |
-> m (Either e a) | Returns |
:: forall e b m a. (Exception e, MonadUnliftIO m, HasCallStack) | |
=> (e -> Maybe b) | |
-> m a | Action to run |
-> m (Either b a) |
withException :: forall e a m b. (Exception e, MonadUnliftIO m, HasCallStack) => m a -> (e -> m b) -> m a Source #
checkpoint :: (MonadUnliftIO m, HasCallStack) => Annotation -> m a -> m a #
Like checkpoint
, but uses MonadUnliftIO
instead of MonadCatch
.
Since: annotated-exception-0.1.2.0
checkpointMany :: (MonadUnliftIO m, HasCallStack) => [Annotation] -> m a -> m a #
Like checkpointMany
, but uses MonadUnliftIO
instead of
MonadCatch
.
Since: annotated-exception-0.1.2.0
:: forall m a. (MonadUnliftIO m, HasCallStack) | |
=> m a | Action that might throw whatever types of exceptions |
-> m a | Action that only throws |
When dealing with a library that does not use AnnotatedException
,
apply this function to augment its exceptions with call stacks.
Miscellany
A value of type
is a computation which, when performed,
does some I/O before returning a value of type IO
aa
.
There is really only one way to "perform" an I/O action: bind it to
Main.main
in your program. When your program is run, the I/O will
be performed. It isn't possible to perform I/O from an arbitrary
function, unless that function is itself in the IO
monad and called
at some point, directly or indirectly, from Main.main
.
IO
is a monad, so IO
actions can be combined using either the do-notation
or the >>
and >>=
operations from the Monad
class.
Instances
class Monad m => MonadIO (m :: Type -> Type) #
Monads in which IO
computations may be embedded.
Any monad built by applying a sequence of monad transformers to the
IO
monad will be an instance of this class.
Instances should satisfy the following laws, which state that liftIO
is a transformer of monads:
Instances
class MonadIO m => MonadUnliftIO (m :: Type -> Type) #
Monads which allow their actions to be run in IO
.
While MonadIO
allows an IO
action to be lifted into another
monad, this class captures the opposite concept: allowing you to
capture the monadic context. Note that, in order to meet the laws
given below, the intuition is that a monad must have no monadic
state, but may have monadic context. This essentially limits
MonadUnliftIO
to ReaderT
and IdentityT
transformers on top of
IO
.
Laws. For any function run
provided by withRunInIO
, it must meet the
monad transformer laws as reformulated for MonadUnliftIO
:
run . return = return
run (m >>= f) = run m >>= run . f
Instances of MonadUnliftIO
must also satisfy the following laws:
- Identity law
withRunInIO (\run -> run m) = m
- Inverse law
withRunInIO (\_ -> m) = liftIO m
As an example of an invalid instance, a naive implementation of
MonadUnliftIO (StateT s m)
might be
withRunInIO inner = StateT $ \s -> withRunInIO $ \run -> inner (run . flip evalStateT s)
This breaks the identity law because the inner run m
would throw away
any state changes in m
.
Since: unliftio-core-0.1.0.0
Instances
module Freckle.App.Exception.Types