-- 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 with to investigate unexceptionalio-trans if you like
--   monad transformers.
@package unexceptionalio
@version 0.4.0

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

-- | IO without any PseudoException
data UIO a

-- | Polymorphic base without any PseudoException
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)

-- | 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 that e covers all exceptions but
--   PseudoException thrown by this IO action
--   
--   This function is partial if you lie
fromIO' :: (Exception e, Unexceptional m) => IO a -> m (Either e 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 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.
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 any PseudoException to the
--   parent thread
fork :: Unexceptional m => UIO () -> m ThreadId
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 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
