unexceptionalio-trans-0.5.1: A wrapper around UnexceptionalIO using monad transformers

Safe HaskellSafe
LanguageHaskell98

UnexceptionalIO.Trans

Contents

Description

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
Synopsis

Documentation

data UIO a #

Like IO, but throws only PseudoException

Instances
Monad UIO 
Instance details

Defined in UnexceptionalIO

Methods

(>>=) :: UIO a -> (a -> UIO b) -> UIO b #

(>>) :: UIO a -> UIO b -> UIO b #

return :: a -> UIO a #

fail :: String -> UIO a #

Functor UIO 
Instance details

Defined in UnexceptionalIO

Methods

fmap :: (a -> b) -> UIO a -> UIO b #

(<$) :: a -> UIO b -> UIO a #

MonadFix UIO 
Instance details

Defined in UnexceptionalIO

Methods

mfix :: (a -> UIO a) -> UIO a #

Applicative UIO 
Instance details

Defined in UnexceptionalIO

Methods

pure :: a -> UIO a #

(<*>) :: UIO (a -> b) -> UIO a -> UIO b #

liftA2 :: (a -> b -> c) -> UIO a -> UIO b -> UIO c #

(*>) :: UIO a -> UIO b -> UIO b #

(<*) :: UIO a -> UIO b -> UIO a #

Unexceptional UIO 
Instance details

Defined in UnexceptionalIO

Methods

lift :: UIO a -> UIO a #

class Monad m => Unexceptional (m :: Type -> Type) where #

Monads in which UIO computations may be embedded

Methods

lift :: UIO a -> m a #

Instances
Unexceptional IO 
Instance details

Defined in UnexceptionalIO

Methods

lift :: UIO a -> IO a #

Unexceptional UIO 
Instance details

Defined in UnexceptionalIO

Methods

lift :: UIO a -> UIO a #

Unexceptional m => Unexceptional (MaybeT m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> MaybeT m a #

Unexceptional m => Unexceptional (ListT m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> ListT m a #

(Unexceptional m, Monoid w) => Unexceptional (WriterT w m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> WriterT w m a #

(Unexceptional m, Monoid w) => Unexceptional (AccumT w m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> AccumT w m a #

(Unexceptional m, Monoid w) => Unexceptional (WriterT w m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> WriterT w m a #

Unexceptional m => Unexceptional (StateT s m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> StateT s m a #

Unexceptional m => Unexceptional (StateT s m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> StateT s m a #

Unexceptional m => Unexceptional (SelectT r m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> SelectT r m a #

Unexceptional m => Unexceptional (IdentityT m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> IdentityT m a #

Unexceptional m => Unexceptional (ExceptT e m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> ExceptT e m a #

(Unexceptional m, Error e) => Unexceptional (ErrorT e m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> ErrorT e m a #

Unexceptional m => Unexceptional (ReaderT r m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> ReaderT r m a #

Unexceptional m => Unexceptional (ContT r m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> ContT r m a #

(Unexceptional m, Monoid w) => Unexceptional (RWST r w s m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> RWST r w s m a #

(Unexceptional m, Monoid w) => Unexceptional (RWST r w s m) Source # 
Instance details

Defined in UnexceptionalIO.Trans

Methods

lift :: UIO a -> RWST r w s m a #

fromIO :: Unexceptional m => IO a -> ExceptT SomeNonPseudoException m a Source #

Catch any exception but PseudoException in an IO action

fromIO' Source #

Arguments

:: (Exception e, Unexceptional m) 
=> (SomeNonPseudoException -> e)

Default if an unexpected exception occurs

-> IO a 
-> ExceptT e m a 

Catch any e in an IO action, with a default mapping for unexpected cases

run :: MonadIO m => UIO a -> m a Source #

Re-embed UIO into MonadIO

runExceptIO :: (Exception e, MonadIO m) => ExceptT e UIO a -> m a Source #

Re-embed UIO and possible exception back into IO

Unsafe entry points

unsafeFromIO :: Unexceptional m => IO a -> m a #

You promise there are no exceptions but PseudoException thrown by this IO action

Pseudo exceptions

data PseudoException #

Not everything handled by the exception system is a run-time error you can handle. This is the class of unrecoverable pseudo-exceptions.

Additionally, except for ExitCode any of these pseudo-exceptions you could never guarantee to have caught. Since they can come from anywhere at any time, we could never guarentee that UIO does not contain them.

Constructors

ProgrammerError ProgrammerError

Mistakes programmers make

ExternalError ExternalError

Errors thrown by the runtime

Exit ExitCode

Process exit requests

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 errors to the parent thread

  • Ignores manual thread kills, since those are on purpose.
  • Re-throws async exceptions (SomeAsyncException) as is.
  • Re-throws ExitCode as is in an attempt to exit with the requested code.
  • Wraps synchronous PseudoException in async ChildThreadError.

newtype ChildThreadError #

Async signal that a child thread ended due to non-async PseudoException

Orphan instances

Unexceptional m => Unexceptional (MaybeT m) Source # 
Instance details

Methods

lift :: UIO a -> MaybeT m a #

Unexceptional m => Unexceptional (ListT m) Source # 
Instance details

Methods

lift :: UIO a -> ListT m a #

(Unexceptional m, Monoid w) => Unexceptional (WriterT w m) Source # 
Instance details

Methods

lift :: UIO a -> WriterT w m a #

(Unexceptional m, Monoid w) => Unexceptional (AccumT w m) Source # 
Instance details

Methods

lift :: UIO a -> AccumT w m a #

(Unexceptional m, Monoid w) => Unexceptional (WriterT w m) Source # 
Instance details

Methods

lift :: UIO a -> WriterT w m a #

Unexceptional m => Unexceptional (StateT s m) Source # 
Instance details

Methods

lift :: UIO a -> StateT s m a #

Unexceptional m => Unexceptional (StateT s m) Source # 
Instance details

Methods

lift :: UIO a -> StateT s m a #

Unexceptional m => Unexceptional (SelectT r m) Source # 
Instance details

Methods

lift :: UIO a -> SelectT r m a #

Unexceptional m => Unexceptional (IdentityT m) Source # 
Instance details

Methods

lift :: UIO a -> IdentityT m a #

Unexceptional m => Unexceptional (ExceptT e m) Source # 
Instance details

Methods

lift :: UIO a -> ExceptT e m a #

(Unexceptional m, Error e) => Unexceptional (ErrorT e m) Source # 
Instance details

Methods

lift :: UIO a -> ErrorT e m a #

Unexceptional m => Unexceptional (ReaderT r m) Source # 
Instance details

Methods

lift :: UIO a -> ReaderT r m a #

Unexceptional m => Unexceptional (ContT r m) Source # 
Instance details

Methods

lift :: UIO a -> ContT r m a #

(Unexceptional m, Monoid w) => Unexceptional (RWST r w s m) Source # 
Instance details

Methods

lift :: UIO a -> RWST r w s m a #

(Unexceptional m, Monoid w) => Unexceptional (RWST r w s m) Source # 
Instance details

Methods

lift :: UIO a -> RWST r w s m a #