module Control.Monad.Trans.InterleavableIO.Control.Exception
( module Control.Exception
, catch
, catchJust
, handle
, handleJust
, try
, tryJust
, throwDynTo
, catchDyn
, bracket
, finally
, bracket_
, bracketOnError
, setUncaughtExceptionHandler
, getUncaughtExceptionHandler
, block
, evaluate
, unblock
, throwTo
, ioError
, throwIO
)
where
import Control.Monad.Trans
import Control.Monad.Trans.InterleavableIO
import Control.Exception hiding
( catch
, catchJust
, handle
, handleJust
, try
, tryJust
, throwDynTo
, catchDyn
, bracket
, finally
, bracket_
, bracketOnError
, setUncaughtExceptionHandler
, getUncaughtExceptionHandler
, block
, evaluate
, unblock
, throwTo
, ioError
, throwIO
)
import qualified Control.Exception
import Prelude hiding
( ioError
, catch
)
import GHC.IOBase hiding
( ioError
, liftIO
, throwIO
)
import Data.Maybe
import Data.Either
import Data.Typeable
import GHC.Conc hiding
( throwTo
)
catch :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer) => trans1 result -> (Exception -> trans2 result) -> trans result
catch a1 a2 = embed $ \ buffer -> Control.Exception.catch (callback buffer a1) (\ b1 -> callback buffer $ a2 b1)
catchJust :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer) => (Exception -> Maybe b) -> trans1 result -> (b -> trans2 result) -> trans result
catchJust a1 a2 a3 = embed $ \ buffer -> Control.Exception.catchJust a1 (callback buffer a2) (\ b1 -> callback buffer $ a3 b1)
handle :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer) => (Exception -> trans1 result) -> trans2 result -> trans result
handle a1 a2 = embed $ \ buffer -> Control.Exception.handle (\ b1 -> callback buffer $ a1 b1) (callback buffer a2)
handleJust :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer) => (Exception -> Maybe b) -> (b -> trans1 result) -> trans2 result -> trans result
handleJust a1 a2 a3 = embed $ \ buffer -> Control.Exception.handleJust a1 (\ b1 -> callback buffer $ a2 b1) (callback buffer a3)
try :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer) => trans1 a -> trans (Either Exception a)
try a1 = embed $ \ buffer -> Control.Exception.try (callback buffer a1)
tryJust :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer) => (Exception -> Maybe b) -> trans1 a -> trans (Either b a)
tryJust a1 a2 = embed $ \ buffer -> Control.Exception.tryJust a1 (callback buffer a2)
throwDynTo :: (MonadIO m, Typeable exception) => ThreadId -> exception -> m ()
throwDynTo a1 a2 = liftIO $ Control.Exception.throwDynTo a1 a2
catchDyn :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer, Typeable exception) => trans1 result -> (exception -> trans2 result) -> trans result
catchDyn a1 a2 = embed $ \ buffer -> Control.Exception.catchDyn (callback buffer a1) (\ b1 -> callback buffer $ a2 b1)
bracket :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer, InterleavableIO IO trans3 buffer) => trans1 a -> (a -> trans2 result) -> (a -> trans3 result1) -> trans result1
bracket a1 a2 a3 = embed $ \ buffer -> Control.Exception.bracket (callback buffer a1) (\ b1 -> callback buffer $ a2 b1) (\ b1 -> callback buffer $ a3 b1)
finally :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer) => trans1 a -> trans2 b -> trans a
finally a1 a2 = embed $ \ buffer -> Control.Exception.finally (callback buffer a1) (callback buffer a2)
bracket_ :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer, InterleavableIO IO trans3 buffer) => trans1 a -> trans2 b -> trans3 c -> trans c
bracket_ a1 a2 a3 = embed $ \ buffer -> Control.Exception.bracket_ (callback buffer a1) (callback buffer a2) (callback buffer a3)
bracketOnError :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer, InterleavableIO IO trans2 buffer, InterleavableIO IO trans3 buffer) => trans1 a -> (a -> trans2 result) -> (a -> trans3 result1) -> trans result1
bracketOnError a1 a2 a3 = embed $ \ buffer -> Control.Exception.bracketOnError (callback buffer a1) (\ b1 -> callback buffer $ a2 b1) (\ b1 -> callback buffer $ a3 b1)
setUncaughtExceptionHandler :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer) => (Exception -> trans1 ()) -> trans ()
setUncaughtExceptionHandler a1 = embed $ \ buffer -> Control.Exception.setUncaughtExceptionHandler (\ b1 -> callback buffer $ a1 b1)
getUncaughtExceptionHandler :: (MonadIO m, MonadIO m1) => m (Exception -> m1 ())
getUncaughtExceptionHandler
= liftIO
$ do
function <- Control.Exception.getUncaughtExceptionHandler
return (\ b1 -> liftIO $ function b1)
block :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer) => trans1 a -> trans a
block a1 = embed $ \ buffer -> Control.Exception.block (callback buffer a1)
evaluate :: (MonadIO m) => a -> m a
evaluate a1 = liftIO $ Control.Exception.evaluate a1
unblock :: (InterleavableIO IO trans buffer, InterleavableIO IO trans1 buffer) => trans1 a -> trans a
unblock a1 = embed $ \ buffer -> Control.Exception.unblock (callback buffer a1)
throwTo :: (MonadIO m) => ThreadId -> Exception -> m ()
throwTo a1 a2 = liftIO $ Control.Exception.throwTo a1 a2
ioError :: (MonadIO m) => IOError -> m a
ioError a1 = liftIO $ Control.Exception.ioError a1
throwIO :: (MonadIO m) => Exception -> m a
throwIO a1 = liftIO $ Control.Exception.throwIO a1