Safe Haskell | Safe |
---|---|
Language | Haskell98 |
When you've caught all the exceptions that can be handled safely, this is what you're left with.
runExceptIO . fromIO ≡ id
It is intended that you use qualified imports with this library.
import UnexceptionalIO.Trans (UIO) import qualified UnexceptionalIO.Trans as UIO
- data UIO a :: * -> *
- class Monad m => Unexceptional (m :: * -> *) where
- fromIO :: Unexceptional m => IO a -> ExceptT SomeNonPseudoException m a
- run :: MonadIO m => UIO a -> m a
- runExceptIO :: (Exception e, MonadIO m) => ExceptT e UIO a -> m a
- fromIO' :: (Exception e, Unexceptional m) => IO a -> ExceptT e m a
- unsafeFromIO :: Unexceptional m => IO a -> m a
- data SomeNonPseudoException :: *
- data PseudoException :: *
- data ProgrammerError :: *
- = TypeError TypeError
- | ArithException ArithException
- | ArrayException ArrayException
- | AssertionFailed AssertionFailed
- | ErrorCall ErrorCall
- | NestedAtomically NestedAtomically
- | NoMethodError NoMethodError
- | PatternMatchFail PatternMatchFail
- | RecConError RecConError
- | RecSelError RecSelError
- | RecUpdError RecSelError
- data ExternalError :: *
- bracket :: Unexceptional m => UIO a -> (a -> UIO ()) -> (a -> UIO c) -> m c
- forkFinally :: Unexceptional m => UIO a -> (Either PseudoException a -> UIO ()) -> m ThreadId
- fork :: Unexceptional m => UIO () -> m ThreadId
Documentation
IO without any PseudoException
class Monad m => Unexceptional (m :: * -> *) where #
Polymorphic base without any PseudoException
fromIO :: Unexceptional m => IO a -> ExceptT SomeNonPseudoException m a Source #
Catch any exception but PseudoException
in an IO
action
runExceptIO :: (Exception e, MonadIO m) => ExceptT e UIO a -> m a Source #
Re-embed UIO
and possible exception back into IO
Unsafe entry points
fromIO' :: (Exception e, Unexceptional m) => IO a -> ExceptT e m a Source #
You promise that e
covers all exceptions but PseudoException
thrown by this IO
action
This function is partial if you lie
unsafeFromIO :: Unexceptional m => IO a -> m a #
You promise there are no exceptions but PseudoException
thrown by this IO
action
Pseudo exceptions
data SomeNonPseudoException :: * #
Every SomeException
but PseudoException
data PseudoException :: * #
Not everything handled by the exception system is a run-time error you can handle. This is the class of pseudo-exceptions you usually can do nothing about, just log or exit.
Additionally, except for ExitCode
any of these psuedo-exceptions
you could never guarentee to have caught, since they can come
from anywhere at any time, we could never guarentee that UIO
does
not contain them.
ProgrammerError ProgrammerError | Mistakes programmers make |
ExternalError ExternalError | Errors thrown by the runtime |
Exit ExitCode | Process exit requests |
data ProgrammerError :: * #
data ExternalError :: * #
Pseudo-exceptions thrown by the runtime environment
Pseudo exception helpers
bracket :: Unexceptional m => UIO a -> (a -> UIO ()) -> (a -> UIO c) -> m c #
When you're doing resource handling, PseudoException
matters.
You still need to use the bracket
pattern to handle cleanup.
forkFinally :: Unexceptional m => UIO a -> (Either PseudoException a -> UIO ()) -> m ThreadId #
Mirrors forkFinally
, but since the body is UIO
,
the thread must terminate successfully or because of PseudoException
fork :: Unexceptional m => UIO () -> m ThreadId #
Mirrors forkIO
, but re-throws any PseudoException
to the parent thread
Orphan instances
Unexceptional m => Unexceptional (MaybeT m) Source # | |
Unexceptional m => Unexceptional (ListT m) Source # | |
(Unexceptional m, Monoid w) => Unexceptional (WriterT w m) Source # | |
(Unexceptional m, Monoid w) => Unexceptional (WriterT w m) Source # | |
Unexceptional m => Unexceptional (StateT s m) Source # | |
Unexceptional m => Unexceptional (StateT s m) Source # | |
Unexceptional m => Unexceptional (IdentityT * m) Source # | |
Unexceptional m => Unexceptional (ExceptT e m) Source # | |
(Unexceptional m, Error e) => Unexceptional (ErrorT e m) Source # | |
Unexceptional m => Unexceptional (ReaderT * r m) Source # | |
Unexceptional m => Unexceptional (ContT * r m) Source # | |
(Unexceptional m, Monoid w) => Unexceptional (RWST r w s m) Source # | |
(Unexceptional m, Monoid w) => Unexceptional (RWST r w s m) Source # | |