Copyright | Bas van Dijk Anders Kaseorg |
---|---|
License | BSD-style |
Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
Stability | experimental |
Portability | non-portable (extended exceptions) |
Safe Haskell | Safe |
Language | Haskell98 |
Control.Exception.Lifted
Description
This is a wrapped version of Control.Exception with types generalized
from IO
to all monads in either MonadBase
or MonadBaseControl
.
Synopsis
- assert :: Bool -> a -> a
- data SomeException = Exception e => SomeException e
- data BlockedIndefinitelyOnMVar = BlockedIndefinitelyOnMVar
- data IOException
- class (Typeable e, Show e) => Exception e where
- toException :: e -> SomeException
- fromException :: SomeException -> Maybe e
- displayException :: e -> String
- mapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a
- throw :: forall (r :: RuntimeRep) (a :: TYPE r) e. Exception e => e -> a
- interruptible :: IO a -> IO a
- asyncExceptionFromException :: Exception e => SomeException -> Maybe e
- asyncExceptionToException :: Exception e => e -> SomeException
- data NestedAtomically = NestedAtomically
- newtype NoMethodError = NoMethodError String
- data NonTermination = NonTermination
- newtype PatternMatchFail = PatternMatchFail String
- newtype RecConError = RecConError String
- newtype RecSelError = RecSelError String
- newtype RecUpdError = RecUpdError String
- newtype TypeError = TypeError String
- data ErrorCall where
- ErrorCallWithLocation String String
- pattern ErrorCall :: String -> ErrorCall
- data ArithException
- data MaskingState
- data AllocationLimitExceeded = AllocationLimitExceeded
- data ArrayException
- = IndexOutOfBounds String
- | UndefinedElement String
- newtype AssertionFailed = AssertionFailed String
- data AsyncException
- data BlockedIndefinitelyOnSTM = BlockedIndefinitelyOnSTM
- newtype CompactionFailed = CompactionFailed String
- data Deadlock = Deadlock
- data SomeAsyncException = Exception e => SomeAsyncException e
- throwIO :: (MonadBase IO m, Exception e) => e -> m a
- ioError :: MonadBase IO m => IOError -> m a
- throwTo :: (MonadBase IO m, Exception e) => ThreadId -> e -> m ()
- catch :: (MonadBaseControl IO m, Exception e) => m a -> (e -> m a) -> m a
- catches :: MonadBaseControl IO m => m a -> [Handler m a] -> m a
- data Handler m a = forall e.Exception e => Handler (e -> m a)
- catchJust :: (MonadBaseControl IO m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a
- handle :: (MonadBaseControl IO m, Exception e) => (e -> m a) -> m a -> m a
- handleJust :: (MonadBaseControl IO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a
- try :: (MonadBaseControl IO m, Exception e) => m a -> m (Either e a)
- tryJust :: (MonadBaseControl IO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)
- evaluate :: MonadBase IO m => a -> m a
- mask :: MonadBaseControl IO m => ((forall a. m a -> m a) -> m b) -> m b
- mask_ :: MonadBaseControl IO m => m a -> m a
- uninterruptibleMask :: MonadBaseControl IO m => ((forall a. m a -> m a) -> m b) -> m b
- uninterruptibleMask_ :: MonadBaseControl IO m => m a -> m a
- getMaskingState :: MonadBase IO m => m MaskingState
- allowInterrupt :: MonadBase IO m => m ()
- bracket :: MonadBaseControl IO m => m a -> (a -> m b) -> (a -> m c) -> m c
- bracket_ :: MonadBaseControl IO m => m a -> m b -> m c -> m c
- bracketOnError :: MonadBaseControl IO m => m a -> (a -> m b) -> (a -> m c) -> m c
- finally :: MonadBaseControl IO m => m a -> m b -> m a
- onException :: MonadBaseControl IO m => m a -> m b -> m a
Documentation
data SomeException #
Constructors
Exception e => SomeException e |
Instances
Show SomeException | |
Defined in GHC.Exception.Type Methods showsPrec :: Int -> SomeException -> ShowS show :: SomeException -> String showList :: [SomeException] -> ShowS | |
Exception SomeException | |
Defined in GHC.Exception.Type Methods toException :: SomeException -> SomeException # fromException :: SomeException -> Maybe SomeException # displayException :: SomeException -> String # |
data BlockedIndefinitelyOnMVar #
Constructors
BlockedIndefinitelyOnMVar |
Instances
Show BlockedIndefinitelyOnMVar | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> BlockedIndefinitelyOnMVar -> ShowS show :: BlockedIndefinitelyOnMVar -> String showList :: [BlockedIndefinitelyOnMVar] -> ShowS | |
Exception BlockedIndefinitelyOnMVar | |
Defined in GHC.IO.Exception Methods toException :: BlockedIndefinitelyOnMVar -> SomeException # fromException :: SomeException -> Maybe BlockedIndefinitelyOnMVar # displayException :: BlockedIndefinitelyOnMVar -> String # |
data IOException #
Instances
Eq IOException | |
Defined in GHC.IO.Exception | |
Show IOException | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> IOException -> ShowS show :: IOException -> String showList :: [IOException] -> ShowS | |
Error IOException | |
Defined in Control.Monad.Trans.Error | |
Exception IOException | |
Defined in GHC.IO.Exception Methods toException :: IOException -> SomeException # fromException :: SomeException -> Maybe IOException # displayException :: IOException -> String # |
class (Typeable e, Show e) => Exception e where #
Minimal complete definition
Nothing
Methods
toException :: e -> SomeException #
fromException :: SomeException -> Maybe e #
displayException :: e -> String #
Instances
mapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a #
interruptible :: IO a -> IO a #
asyncExceptionFromException :: Exception e => SomeException -> Maybe e #
asyncExceptionToException :: Exception e => e -> SomeException #
data NestedAtomically #
Constructors
NestedAtomically |
Instances
Show NestedAtomically | |
Defined in Control.Exception.Base Methods showsPrec :: Int -> NestedAtomically -> ShowS show :: NestedAtomically -> String showList :: [NestedAtomically] -> ShowS | |
Exception NestedAtomically | |
Defined in Control.Exception.Base Methods toException :: NestedAtomically -> SomeException # fromException :: SomeException -> Maybe NestedAtomically # displayException :: NestedAtomically -> String # |
newtype NoMethodError #
Constructors
NoMethodError String |
Instances
Show NoMethodError | |
Defined in Control.Exception.Base Methods showsPrec :: Int -> NoMethodError -> ShowS show :: NoMethodError -> String showList :: [NoMethodError] -> ShowS | |
Exception NoMethodError | |
Defined in Control.Exception.Base Methods toException :: NoMethodError -> SomeException # fromException :: SomeException -> Maybe NoMethodError # displayException :: NoMethodError -> String # |
data NonTermination #
Constructors
NonTermination |
Instances
Show NonTermination | |
Defined in Control.Exception.Base Methods showsPrec :: Int -> NonTermination -> ShowS show :: NonTermination -> String showList :: [NonTermination] -> ShowS | |
Exception NonTermination | |
Defined in Control.Exception.Base Methods toException :: NonTermination -> SomeException # fromException :: SomeException -> Maybe NonTermination # displayException :: NonTermination -> String # |
newtype PatternMatchFail #
Constructors
PatternMatchFail String |
Instances
Show PatternMatchFail | |
Defined in Control.Exception.Base Methods showsPrec :: Int -> PatternMatchFail -> ShowS show :: PatternMatchFail -> String showList :: [PatternMatchFail] -> ShowS | |
Exception PatternMatchFail | |
Defined in Control.Exception.Base Methods toException :: PatternMatchFail -> SomeException # fromException :: SomeException -> Maybe PatternMatchFail # displayException :: PatternMatchFail -> String # |
newtype RecConError #
Constructors
RecConError String |
Instances
Show RecConError | |
Defined in Control.Exception.Base Methods showsPrec :: Int -> RecConError -> ShowS show :: RecConError -> String showList :: [RecConError] -> ShowS | |
Exception RecConError | |
Defined in Control.Exception.Base Methods toException :: RecConError -> SomeException # fromException :: SomeException -> Maybe RecConError # displayException :: RecConError -> String # |
newtype RecSelError #
Constructors
RecSelError String |
Instances
Show RecSelError | |
Defined in Control.Exception.Base Methods showsPrec :: Int -> RecSelError -> ShowS show :: RecSelError -> String showList :: [RecSelError] -> ShowS | |
Exception RecSelError | |
Defined in Control.Exception.Base Methods toException :: RecSelError -> SomeException # fromException :: SomeException -> Maybe RecSelError # displayException :: RecSelError -> String # |
newtype RecUpdError #
Constructors
RecUpdError String |
Instances
Show RecUpdError | |
Defined in Control.Exception.Base Methods showsPrec :: Int -> RecUpdError -> ShowS show :: RecUpdError -> String showList :: [RecUpdError] -> ShowS | |
Exception RecUpdError | |
Defined in Control.Exception.Base Methods toException :: RecUpdError -> SomeException # fromException :: SomeException -> Maybe RecUpdError # displayException :: RecUpdError -> String # |
Constructors
TypeError String |
Instances
Show TypeError | |
Exception TypeError | |
Defined in Control.Exception.Base Methods toException :: TypeError -> SomeException # fromException :: SomeException -> Maybe TypeError # displayException :: TypeError -> String # |
Constructors
ErrorCallWithLocation String String |
Instances
Eq ErrorCall | |
Ord ErrorCall | |
Defined in GHC.Exception | |
Show ErrorCall | |
Exception ErrorCall | |
Defined in GHC.Exception Methods toException :: ErrorCall -> SomeException # fromException :: SomeException -> Maybe ErrorCall # displayException :: ErrorCall -> String # |
data ArithException #
Instances
Eq ArithException | |
Defined in GHC.Exception.Type Methods (==) :: ArithException -> ArithException -> Bool (/=) :: ArithException -> ArithException -> Bool | |
Ord ArithException | |
Defined in GHC.Exception.Type Methods compare :: ArithException -> ArithException -> Ordering (<) :: ArithException -> ArithException -> Bool (<=) :: ArithException -> ArithException -> Bool (>) :: ArithException -> ArithException -> Bool (>=) :: ArithException -> ArithException -> Bool max :: ArithException -> ArithException -> ArithException min :: ArithException -> ArithException -> ArithException | |
Show ArithException | |
Defined in GHC.Exception.Type Methods showsPrec :: Int -> ArithException -> ShowS show :: ArithException -> String showList :: [ArithException] -> ShowS | |
Exception ArithException | |
Defined in GHC.Exception.Type Methods toException :: ArithException -> SomeException # fromException :: SomeException -> Maybe ArithException # displayException :: ArithException -> String # |
data MaskingState #
Constructors
Unmasked | |
MaskedInterruptible | |
MaskedUninterruptible |
Instances
Eq MaskingState | |
Defined in GHC.IO | |
Show MaskingState | |
Defined in GHC.IO Methods showsPrec :: Int -> MaskingState -> ShowS show :: MaskingState -> String showList :: [MaskingState] -> ShowS |
data AllocationLimitExceeded #
Constructors
AllocationLimitExceeded |
Instances
Show AllocationLimitExceeded | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> AllocationLimitExceeded -> ShowS show :: AllocationLimitExceeded -> String showList :: [AllocationLimitExceeded] -> ShowS | |
Exception AllocationLimitExceeded | |
Defined in GHC.IO.Exception Methods toException :: AllocationLimitExceeded -> SomeException # fromException :: SomeException -> Maybe AllocationLimitExceeded # displayException :: AllocationLimitExceeded -> String # |
data ArrayException #
Constructors
IndexOutOfBounds String | |
UndefinedElement String |
Instances
Eq ArrayException | |
Defined in GHC.IO.Exception Methods (==) :: ArrayException -> ArrayException -> Bool (/=) :: ArrayException -> ArrayException -> Bool | |
Ord ArrayException | |
Defined in GHC.IO.Exception Methods compare :: ArrayException -> ArrayException -> Ordering (<) :: ArrayException -> ArrayException -> Bool (<=) :: ArrayException -> ArrayException -> Bool (>) :: ArrayException -> ArrayException -> Bool (>=) :: ArrayException -> ArrayException -> Bool max :: ArrayException -> ArrayException -> ArrayException min :: ArrayException -> ArrayException -> ArrayException | |
Show ArrayException | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> ArrayException -> ShowS show :: ArrayException -> String showList :: [ArrayException] -> ShowS | |
Exception ArrayException | |
Defined in GHC.IO.Exception Methods toException :: ArrayException -> SomeException # fromException :: SomeException -> Maybe ArrayException # displayException :: ArrayException -> String # |
newtype AssertionFailed #
Constructors
AssertionFailed String |
Instances
Show AssertionFailed | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> AssertionFailed -> ShowS show :: AssertionFailed -> String showList :: [AssertionFailed] -> ShowS | |
Exception AssertionFailed | |
Defined in GHC.IO.Exception Methods toException :: AssertionFailed -> SomeException # fromException :: SomeException -> Maybe AssertionFailed # displayException :: AssertionFailed -> String # |
data AsyncException #
Constructors
StackOverflow | |
HeapOverflow | |
ThreadKilled | |
UserInterrupt |
Instances
Eq AsyncException | |
Defined in GHC.IO.Exception Methods (==) :: AsyncException -> AsyncException -> Bool (/=) :: AsyncException -> AsyncException -> Bool | |
Ord AsyncException | |
Defined in GHC.IO.Exception Methods compare :: AsyncException -> AsyncException -> Ordering (<) :: AsyncException -> AsyncException -> Bool (<=) :: AsyncException -> AsyncException -> Bool (>) :: AsyncException -> AsyncException -> Bool (>=) :: AsyncException -> AsyncException -> Bool max :: AsyncException -> AsyncException -> AsyncException min :: AsyncException -> AsyncException -> AsyncException | |
Show AsyncException | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> AsyncException -> ShowS show :: AsyncException -> String showList :: [AsyncException] -> ShowS | |
Exception AsyncException | |
Defined in GHC.IO.Exception Methods toException :: AsyncException -> SomeException # fromException :: SomeException -> Maybe AsyncException # displayException :: AsyncException -> String # |
data BlockedIndefinitelyOnSTM #
Constructors
BlockedIndefinitelyOnSTM |
Instances
Show BlockedIndefinitelyOnSTM | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> BlockedIndefinitelyOnSTM -> ShowS show :: BlockedIndefinitelyOnSTM -> String showList :: [BlockedIndefinitelyOnSTM] -> ShowS | |
Exception BlockedIndefinitelyOnSTM | |
Defined in GHC.IO.Exception Methods toException :: BlockedIndefinitelyOnSTM -> SomeException # fromException :: SomeException -> Maybe BlockedIndefinitelyOnSTM # displayException :: BlockedIndefinitelyOnSTM -> String # |
newtype CompactionFailed #
Constructors
CompactionFailed String |
Instances
Show CompactionFailed | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> CompactionFailed -> ShowS show :: CompactionFailed -> String showList :: [CompactionFailed] -> ShowS | |
Exception CompactionFailed | |
Defined in GHC.IO.Exception Methods toException :: CompactionFailed -> SomeException # fromException :: SomeException -> Maybe CompactionFailed # displayException :: CompactionFailed -> String # |
Constructors
Deadlock |
Instances
Show Deadlock | |
Exception Deadlock | |
Defined in GHC.IO.Exception Methods toException :: Deadlock -> SomeException # fromException :: SomeException -> Maybe Deadlock # displayException :: Deadlock -> String # |
data SomeAsyncException #
Constructors
Exception e => SomeAsyncException e |
Instances
Show SomeAsyncException | |
Defined in GHC.IO.Exception Methods showsPrec :: Int -> SomeAsyncException -> ShowS show :: SomeAsyncException -> String showList :: [SomeAsyncException] -> ShowS | |
Exception SomeAsyncException | |
Defined in GHC.IO.Exception Methods toException :: SomeAsyncException -> SomeException # fromException :: SomeException -> Maybe SomeAsyncException # displayException :: SomeAsyncException -> String # |
Throwing exceptions
throwTo :: (MonadBase IO m, Exception e) => ThreadId -> e -> m () Source #
Generalized version of throwTo
.
Catching exceptions
The catch
functions
Arguments
:: (MonadBaseControl IO m, Exception e) | |
=> m a | The computation to run |
-> (e -> m a) | Handler to invoke if an exception is raised |
-> m a |
Generalized version of catch
.
Note, when the given computation throws an exception any monadic
side effects in m
will be discarded.
catches :: MonadBaseControl IO m => m a -> [Handler m a] -> m a Source #
Generalized version of catches
.
Note, when the given computation throws an exception any monadic
side effects in m
will be discarded.
Generalized version of Handler
.
Arguments
:: (MonadBaseControl IO m, Exception e) | |
=> (e -> Maybe b) | Predicate to select exceptions |
-> m a | Computation to run |
-> (b -> m a) | Handler |
-> m a |
Generalized version of catchJust
.
Note, when the given computation throws an exception any monadic
side effects in m
will be discarded.
The handle
functions
handle :: (MonadBaseControl IO m, Exception e) => (e -> m a) -> m a -> m a Source #
Generalized version of handle
.
Note, when the given computation throws an exception any monadic
side effects in m
will be discarded.
handleJust :: (MonadBaseControl IO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a Source #
Generalized version of handleJust
.
Note, when the given computation throws an exception any monadic
side effects in m
will be discarded.
The try
functions
try :: (MonadBaseControl IO m, Exception e) => m a -> m (Either e a) Source #
Generalized version of try
.
Note, when the given computation throws an exception any monadic
side effects in m
will be discarded.
tryJust :: (MonadBaseControl IO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a) Source #
Generalized version of tryJust
.
Note, when the given computation throws an exception any monadic
side effects in m
will be discarded.
The evaluate
function
Asynchronous Exceptions
Asynchronous exception control
The following functions allow a thread to control delivery of asynchronous exceptions during a critical region.
mask :: MonadBaseControl IO m => ((forall a. m a -> m a) -> m b) -> m b Source #
Generalized version of mask
.
mask_ :: MonadBaseControl IO m => m a -> m a Source #
Generalized version of mask_
.
uninterruptibleMask :: MonadBaseControl IO m => ((forall a. m a -> m a) -> m b) -> m b Source #
Generalized version of uninterruptibleMask
.
uninterruptibleMask_ :: MonadBaseControl IO m => m a -> m a Source #
Generalized version of uninterruptibleMask_
.
getMaskingState :: MonadBase IO m => m MaskingState Source #
Generalized version of getMaskingState
.
allowInterrupt :: MonadBase IO m => m () Source #
Generalized version of allowInterrupt
.
Brackets
Arguments
:: MonadBaseControl IO m | |
=> m a | computation to run first ("acquire resource") |
-> (a -> m b) | computation to run last ("release resource") |
-> (a -> m c) | computation to run in-between |
-> m c |
Generalized version of bracket
.
Note:
- When the "acquire" or "release" computations throw exceptions
any monadic side effects in
m
will be discarded. - When the "in-between" computation throws an exception any
monadic side effects in
m
produced by that computation will be discarded but the side effects of the "acquire" or "release" computations will be retained. - Also, any monadic side effects in
m
of the "release" computation will be discarded; it is run only for its side effects inIO
.
Note that when your acquire
and release
computations are of type IO
it will be more efficient to write:
liftBaseOp
(bracket
acquire release)
Arguments
:: MonadBaseControl IO m | |
=> m a | computation to run first ("acquire resource") |
-> m b | computation to run last ("release resource") |
-> m c | computation to run in-between |
-> m c |
Generalized version of bracket_
.
Note any monadic side effects in m
of both the "acquire" and
"release" computations will be discarded. To keep the monadic
side effects of the "acquire" computation, use bracket
with
constant functions instead.
Note that when your acquire
and release
computations are of type IO
it will be more efficient to write:
liftBaseOp_
(bracket_
acquire release)
Arguments
:: MonadBaseControl IO m | |
=> m a | computation to run first ("acquire resource") |
-> (a -> m b) | computation to run last ("release resource") |
-> (a -> m c) | computation to run in-between |
-> m c |
Generalized version of bracketOnError
.
Note:
- When the "acquire" or "release" computations throw exceptions
any monadic side effects in
m
will be discarded. - When the "in-between" computation throws an exception any
monadic side effects in
m
produced by that computation will be discarded but the side effects of the "acquire" computation will be retained. - Also, any monadic side effects in
m
of the "release" computation will be discarded; it is run only for its side effects inIO
.
Note that when your acquire
and release
computations are of
type IO
it will be more efficient to write:
liftBaseOp
(bracketOnError
acquire release)
Utilities
Arguments
:: MonadBaseControl IO m | |
=> m a | computation to run first |
-> m b | computation to run afterward (even if an exception was raised) |
-> m a |
Generalized version of finally
.
Note, any monadic side effects in m
of the "afterward"
computation will be discarded.
onException :: MonadBaseControl IO m => m a -> m b -> m a Source #
Generalized version of onException
.
Note, any monadic side effects in m
of the "afterward"
computation will be discarded.