unexceptionalio-0.4.0: IO without any non-error, synchronous exceptions

Safe HaskellSafe
LanguageHaskell98

UnexceptionalIO

Contents

Description

When you've caught all the exceptions that can be handled safely, this is what you're left with.

runEitherIO . fromIO ≡ id

It is intended that you use qualified imports with this library.

import UnexceptionalIO (UIO)
import qualified UnexceptionalIO as UIO

Synopsis

Documentation

data UIO a Source #

IO without any PseudoException

Instances

Monad UIO Source # 

Methods

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

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

return :: a -> UIO a #

fail :: String -> UIO a #

Functor UIO Source # 

Methods

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

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

MonadFix UIO Source # 

Methods

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

Applicative UIO Source # 

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 Source # 

Methods

lift :: UIO a -> UIO a Source #

class Monad m => Unexceptional m where Source #

Polymorphic base without any PseudoException

Minimal complete definition

lift

Methods

lift :: UIO a -> m a Source #

Instances

Unexceptional IO Source # 

Methods

lift :: UIO a -> IO a Source #

Unexceptional UIO Source # 

Methods

lift :: UIO a -> UIO a Source #

fromIO :: Unexceptional m => IO a -> m (Either SomeNonPseudoException a) Source #

Catch any exception but PseudoException in an IO action

run :: UIO a -> IO a Source #

Re-embed UIO into IO

runEitherIO :: Exception e => UIO (Either e a) -> IO a Source #

Re-embed UIO and possible exception back into IO

Unsafe entry points

fromIO' :: (Exception e, Unexceptional m) => IO a -> m (Either e 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 Source #

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

Pseudo exceptions

data PseudoException Source #

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.

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 Source #

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 Source #

Mirrors forkFinally, but since the body is UIO, the thread must terminate successfully or because of PseudoException

fork :: Unexceptional m => UIO () -> m ThreadId Source #

Mirrors forkIO, but re-throws any PseudoException to the parent thread