Safe Haskell | None |
---|---|
Language | GHC2021 |
Freckle.App.Exception.MonadUnliftIO
Contents
Synopsis
- throwM :: (Exception e, MonadIO m, HasCallStack) => e -> m a
- throwString :: (MonadIO m, HasCallStack) => String -> m a
- fromJustNoteM :: (MonadIO m, HasCallStack) => String -> Maybe a -> m a
- impossible :: (MonadIO m, HasCallStack) => m a
- catch :: (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 :: (MonadUnliftIO m, HasCallStack) => m a -> [ExceptionHandler m a] -> m a
- try :: (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 :: (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 :: (MonadIO m, HasCallStack) => String -> m a Source #
fromJustNoteM :: (MonadIO m, HasCallStack) => String -> Maybe a -> m a Source #
impossible :: (MonadIO m, HasCallStack) => m a Source #
catch :: (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 #
Arguments
:: (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 |
Arguments
:: (Exception e, MonadUnliftIO m, HasCallStack) | |
=> m a | Action to run |
-> m (Either e a) | Returns |
Arguments
:: 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
Arguments
:: (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
MonadFail IO | Since: base-4.9.0.0 |
Defined in Control.Monad.Fail | |
MonadFix IO | Since: base-2.1 |
Defined in Control.Monad.Fix | |
MonadIO IO | Since: base-4.9.0.0 |
Defined in Control.Monad.IO.Class | |
Alternative IO | Takes the first non-throwing Since: base-4.9.0.0 |
Applicative IO | Since: base-2.1 |
Functor IO | Since: base-2.1 |
Monad IO | Since: base-2.1 |
MonadPlus IO | Takes the first non-throwing Since: base-4.9.0.0 |
GHCiSandboxIO IO | Since: base-4.4.0.0 |
Defined in GHC.GHCi Methods ghciStepIO :: IO a -> IO a # | |
MonadCatch IO | |
Defined in Control.Monad.Catch | |
MonadMask IO | |
Defined in Control.Monad.Catch Methods mask :: HasCallStack => ((forall a. IO a -> IO a) -> IO b) -> IO b # uninterruptibleMask :: HasCallStack => ((forall a. IO a -> IO a) -> IO b) -> IO b # generalBracket :: HasCallStack => IO a -> (a -> ExitCase b -> IO c) -> (a -> IO b) -> IO (b, c) # | |
MonadThrow IO | |
Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> IO a # | |
PrimBase IO | |
PrimMonad IO | |
MonadUnliftIO IO | |
Defined in Control.Monad.IO.Unlift | |
MonadBaseControl IO IO | |
Monoid a => Monoid (IO a) | Since: base-4.9.0.0 |
Semigroup a => Semigroup (IO a) | Since: base-4.10.0.0 |
a ~ () => HPrintfType (IO a) | Since: base-4.7.0.0 |
Defined in Text.Printf | |
a ~ () => PrintfType (IO a) | Since: base-4.7.0.0 |
Defined in Text.Printf | |
type PrimState IO | |
Defined in Control.Monad.Primitive | |
type StM IO a | |
Defined in Control.Monad.Trans.Control |
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:
Minimal complete definition
Instances
MonadIO IO | Since: base-4.9.0.0 |
Defined in Control.Monad.IO.Class | |
MonadIO m => MonadIO (CatchT m) | |
Defined in Control.Monad.Catch.Pure | |
MonadIO m => MonadIO (LoggingT m) | |
Defined in Control.Monad.Logger | |
MonadIO m => MonadIO (NoLoggingT m) | |
Defined in Control.Monad.Logger Methods liftIO :: IO a -> NoLoggingT m a # | |
MonadIO m => MonadIO (WriterLoggingT m) | |
Defined in Control.Monad.Logger Methods liftIO :: IO a -> WriterLoggingT m a # | |
MonadIO m => MonadIO (ResourceT m) | |
Defined in Control.Monad.Trans.Resource.Internal | |
(Monoid w, Functor m, MonadIO m) => MonadIO (AccumT w m) | |
Defined in Control.Monad.Trans.Accum | |
MonadIO m => MonadIO (SelectT r m) | |
Defined in Control.Monad.Trans.Select | |
MonadIO m => MonadIO (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.CPS | |
MonadIO m => MonadIO (ConduitT i o m) | |
Defined in Data.Conduit.Internal.Conduit | |
MonadIO m => MonadIO (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.CPS | |
MonadIO m => MonadIO (Pipe l i o u m) | |
Defined in Data.Conduit.Internal.Pipe |
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
Minimal complete definition
Instances
MonadUnliftIO IO | |
Defined in Control.Monad.IO.Unlift | |
MonadUnliftIO m => MonadUnliftIO (LoggingT m) | Since: monad-logger-0.3.26 |
Defined in Control.Monad.Logger | |
MonadUnliftIO m => MonadUnliftIO (NoLoggingT m) | Since: monad-logger-0.3.26 |
Defined in Control.Monad.Logger Methods withRunInIO :: ((forall a. NoLoggingT m a -> IO a) -> IO b) -> NoLoggingT m b # | |
MonadUnliftIO m => MonadUnliftIO (ResourceT m) | Since: resourcet-1.1.10 |
Defined in Control.Monad.Trans.Resource.Internal | |
MonadUnliftIO m => MonadUnliftIO (IdentityT m) | |
Defined in Control.Monad.IO.Unlift | |
MonadUnliftIO m => MonadUnliftIO (ReaderT r m) | |
Defined in Control.Monad.IO.Unlift |
module Freckle.App.Exception.Types