-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | IO without any non-error, synchronous exceptions
--   
--   When you've caught all the exceptions that can be handled safely, this
--   is what you're left with.
--   
--   It is intended that you use qualified imports with this library.
--   
--   
--   import UnexceptionalIO (UIO)
--   import qualified UnexceptionalIO as UIO
--   
--   
--   You may also wish to investigate unexceptionalio-trans if you like
--   monad transformers.
--   
--   Blog post: http://sngpl.ma/p4uT0
@package unexceptionalio
@version 0.5.1

-- | 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
--   
module UnexceptionalIO

-- | Like IO, but throws only PseudoException
data UIO a

-- | Monads in which UIO computations may be embedded
class (Monad m) => Unexceptional m
lift :: Unexceptional m => UIO a -> m a

-- | Catch any exception but PseudoException in an IO action
fromIO :: Unexceptional m => IO a -> m (Either SomeNonPseudoException a)

-- | Catch any e in an IO action, with a default mapping
--   for unexpected cases
fromIO' :: (Exception e, Unexceptional m) => (SomeNonPseudoException -> e) -> IO a -> m (Either e a)

-- | Re-embed UIO into IO
run :: UIO a -> IO a

-- | Re-embed UIO and possible exception back into IO
runEitherIO :: Exception e => UIO (Either e a) -> IO a

-- | You promise there are no exceptions but PseudoException thrown
--   by this IO action
unsafeFromIO :: Unexceptional m => IO a -> m a

-- | Every SomeException but PseudoException
data SomeNonPseudoException

-- | 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.
data PseudoException

-- | Mistakes programmers make
ProgrammerError :: ProgrammerError -> PseudoException

-- | Errors thrown by the runtime
ExternalError :: ExternalError -> PseudoException

-- | Process exit requests
Exit :: ExitCode -> PseudoException

-- | Pseudo-exceptions caused by a programming error
--   
--   Partial functions, error, undefined, etc
data ProgrammerError
TypeError :: TypeError -> ProgrammerError
ArithException :: ArithException -> ProgrammerError
ArrayException :: ArrayException -> ProgrammerError
AssertionFailed :: AssertionFailed -> ProgrammerError
ErrorCall :: ErrorCall -> ProgrammerError
NestedAtomically :: NestedAtomically -> ProgrammerError
NoMethodError :: NoMethodError -> ProgrammerError
PatternMatchFail :: PatternMatchFail -> ProgrammerError
RecConError :: RecConError -> ProgrammerError
RecSelError :: RecSelError -> ProgrammerError
RecUpdError :: RecSelError -> ProgrammerError

-- | Pseudo-exceptions thrown by the runtime environment
data ExternalError
CompactionFailed :: CompactionFailed -> ExternalError
FixIOException :: FixIOException -> ExternalError
AsyncException :: SomeAsyncException -> ExternalError
BlockedIndefinitelyOnSTM :: BlockedIndefinitelyOnSTM -> ExternalError
BlockedIndefinitelyOnMVar :: BlockedIndefinitelyOnMVar -> ExternalError
Deadlock :: Deadlock -> ExternalError
NonTermination :: NonTermination -> ExternalError

-- | When you're doing resource handling, PseudoException matters.
--   You still need to use the bracket pattern to handle cleanup.
bracket :: Unexceptional m => UIO a -> (a -> UIO ()) -> (a -> UIO c) -> m c

-- | Mirrors forkFinally, but since the body is UIO, the
--   thread must terminate successfully or because of
--   PseudoException
forkFinally :: Unexceptional m => UIO a -> (Either PseudoException a -> 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.
--   
fork :: Unexceptional m => UIO () -> m ThreadId

-- | Async signal that a child thread ended due to non-async
--   PseudoException
newtype ChildThreadError
ChildThreadError :: PseudoException -> ChildThreadError
instance GHC.Show.Show UnexceptionalIO.ChildThreadError
instance GHC.Show.Show UnexceptionalIO.SomeNonPseudoException
instance GHC.Show.Show UnexceptionalIO.PseudoException
instance GHC.Show.Show UnexceptionalIO.ExternalError
instance GHC.Show.Show UnexceptionalIO.ProgrammerError
instance GHC.Exception.Type.Exception UnexceptionalIO.ChildThreadError
instance UnexceptionalIO.Unexceptional UnexceptionalIO.UIO
instance UnexceptionalIO.Unexceptional GHC.Types.IO
instance GHC.Base.Functor UnexceptionalIO.UIO
instance GHC.Base.Applicative UnexceptionalIO.UIO
instance GHC.Base.Monad UnexceptionalIO.UIO
instance Control.Monad.Fix.MonadFix UnexceptionalIO.UIO
instance GHC.Exception.Type.Exception UnexceptionalIO.SomeNonPseudoException
instance GHC.Exception.Type.Exception UnexceptionalIO.PseudoException
instance GHC.Exception.Type.Exception UnexceptionalIO.ExternalError
instance GHC.Exception.Type.Exception UnexceptionalIO.ProgrammerError
