| Copyright | (c) Alexey Kuleshevich 2020 | 
|---|---|
| License | BSD3 | 
| Maintainer | Alexey Kuleshevich <alexey@kuleshevi.ch> | 
| Stability | experimental | 
| Portability | non-portable | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
Control.Prim.Exception
Description
Synopsis
- module Control.Prim.Monad.Throw
 - throw :: (Exception e, MonadPrim s m) => e -> m a
 - throwTo :: (MonadPrim s m, Exception e) => ThreadId -> e -> m ()
 - impureThrow :: Exception e => e -> a
 - catch :: forall e a m. (Exception e, MonadUnliftPrim RW m) => m a -> (e -> m a) -> m a
 - catchAny :: forall a m. MonadUnliftPrim RW m => m a -> (SomeException -> m a) -> m a
 - catchAnySync :: forall a m. MonadUnliftPrim RW m => m a -> (SomeException -> m a) -> m a
 - catchAll :: forall a m. MonadUnliftPrim RW m => m a -> (forall e. Exception e => e -> m a) -> m a
 - catchAllSync :: forall a m. MonadUnliftPrim RW m => m a -> (forall e. Exception e => e -> m a) -> m a
 - try :: (Exception e, MonadUnliftPrim RW m) => m a -> m (Either e a)
 - tryAny :: MonadUnliftPrim RW m => m a -> m (Either SomeException a)
 - tryAnySync :: MonadUnliftPrim RW m => m a -> m (Either SomeException a)
 - onException :: MonadUnliftPrim RW m => m a -> m b -> m a
 - withException :: (MonadUnliftPrim RW m, Exception e) => m a -> (e -> m b) -> m a
 - withAnyException :: MonadUnliftPrim RW m => m a -> (SomeException -> m b) -> m a
 - finally :: MonadUnliftPrim RW m => m a -> m b -> m a
 - bracket :: MonadUnliftPrim RW m => m a -> (a -> m b) -> (a -> m c) -> m c
 - bracket_ :: MonadUnliftPrim RW m => m a -> m b -> m c -> m c
 - bracketOnError :: MonadUnliftPrim RW m => m a -> (a -> m b) -> (a -> m c) -> m c
 - ufinally :: MonadUnliftPrim RW m => m a -> m b -> m a
 - ubracket :: MonadUnliftPrim RW m => m a -> (a -> m b) -> (a -> m c) -> m c
 - ubracket_ :: MonadUnliftPrim RW m => m a -> m b -> m c -> m c
 - ubracketOnError :: MonadUnliftPrim RW m => m a -> (a -> m b) -> (a -> m c) -> m c
 - mask :: forall a m s. MonadUnliftPrim s m => ((forall b. m b -> m b) -> m a) -> m a
 - mask_ :: forall a m s. MonadUnliftPrim s m => m a -> m a
 - maskPrimBase_ :: forall a n m s. (MonadPrim s m, MonadPrimBase s n) => n a -> m a
 - uninterruptibleMask :: forall a m s. MonadUnliftPrim s m => ((forall b. m b -> m b) -> m a) -> m a
 - uninterruptibleMask_ :: forall a m s. MonadUnliftPrim s m => m a -> m a
 - uninterruptibleMaskPrimBase_ :: forall a n m s. (MonadPrimBase s n, MonadPrim s m) => n a -> m a
 - maskAsyncExceptions :: forall a m. MonadUnliftPrim RW m => m a -> m a
 - unmaskAsyncExceptions :: forall a m. MonadUnliftPrim RW m => m a -> m a
 - maskUninterruptible :: forall a m. MonadUnliftPrim RW m => m a -> m a
 - data MaskingState
 - getMaskingState :: MonadPrim RW m => m MaskingState
 - class (Typeable e, Show e) => Exception e where
- toException :: e -> SomeException
 - fromException :: SomeException -> Maybe e
 - displayException :: e -> String
 
 - data SomeException
 - data AsyncException
 - data SomeAsyncException = Exception e => SomeAsyncException e
 - isSyncException :: Exception e => e -> Bool
 - isAsyncException :: Exception e => e -> Bool
 - asyncExceptionToException :: Exception e => e -> SomeException
 - asyncExceptionFromException :: Exception e => SomeException -> Maybe e
 - data ErrorCall where
 - data ArithException
 - data ArrayException
 - newtype AssertionFailed = AssertionFailed String
 - data IOException
 - data NonTermination = NonTermination
 - data NestedAtomically = NestedAtomically
 - data BlockedIndefinitelyOnMVar = BlockedIndefinitelyOnMVar
 - data BlockedIndefinitelyOnSTM = BlockedIndefinitelyOnSTM
 - data AllocationLimitExceeded = AllocationLimitExceeded
 - data Deadlock = Deadlock
 - data CallStack
 - type HasCallStack = ?callStack :: CallStack
 - callStack :: HasCallStack => CallStack
 - getCallStack :: CallStack -> [([Char], SrcLoc)]
 - prettyCallStack :: CallStack -> String
 - data SrcLoc = SrcLoc {
- srcLocPackage :: [Char]
 - srcLocModule :: [Char]
 - srcLocFile :: [Char]
 - srcLocStartLine :: Int
 - srcLocStartCol :: Int
 - srcLocEndLine :: Int
 - srcLocEndCol :: Int
 
 - prettySrcLoc :: SrcLoc -> String
 - module Control.Prim.Monad
 
Throwing
module Control.Prim.Monad.Throw
throwTo :: (MonadPrim s m, Exception e) => ThreadId -> e -> m () Source #
Similar to throwTo, except that it wraps any known non-async exception with
 SomeAsyncException. This is necessary, because receiving thread will get the exception in
 an asynchronous manner and without proper wrapping it will not be able to distinguish it
 from a regular synchronous exception
impureThrow :: Exception e => e -> a Source #
Raise an impure exception from pure code. Returns a thunk, which will result in a supplied exceptionn being thrown when evaluated.
Since: 0.3.0
Catching
catch :: forall e a m. (Exception e, MonadUnliftPrim RW m) => m a -> (e -> m a) -> m a Source #
Behaves exactly as catch, except that it works in any MonadUnliftPrim.
catchAny :: forall a m. MonadUnliftPrim RW m => m a -> (SomeException -> m a) -> m a Source #
catchAnySync :: forall a m. MonadUnliftPrim RW m => m a -> (SomeException -> m a) -> m a Source #
catchAll :: forall a m. MonadUnliftPrim RW m => m a -> (forall e. Exception e => e -> m a) -> m a Source #
catchAllSync :: forall a m. MonadUnliftPrim RW m => m a -> (forall e. Exception e => e -> m a) -> m a Source #
tryAny :: MonadUnliftPrim RW m => m a -> m (Either SomeException a) Source #
tryAnySync :: MonadUnliftPrim RW m => m a -> m (Either SomeException a) Source #
onException :: MonadUnliftPrim RW m => m a -> m b -> m a Source #
Async safe version of onException.
Since: 0.1.0.0
withException :: (MonadUnliftPrim RW m, Exception e) => m a -> (e -> m b) -> m a Source #
Run an action, while invoking an exception handler if that action fails for some reason. Exception handling function has async exceptions masked, but it is still interruptible, which can be undesired in some scenarios. If you are sure that the cleanup action does not deadlock and you do need hard guarantees that it gets executed you can run it as uninterruptible:
uninterruptibleMask $ \restore -> withException (restore action) handler
Since: 0.3.0
withAnyException :: MonadUnliftPrim RW m => m a -> (SomeException -> m b) -> m a Source #
Same as withException, but will invoke exception handling function on all
 exceptions.
Since: 0.3.0
finally :: MonadUnliftPrim RW m => m a -> m b -> m a Source #
bracket :: MonadUnliftPrim RW m => m a -> (a -> m b) -> (a -> m c) -> m c Source #
bracket_ :: MonadUnliftPrim RW m => m a -> m b -> m c -> m c Source #
bracketOnError :: MonadUnliftPrim RW m => m a -> (a -> m b) -> (a -> m c) -> m c Source #
ufinally :: MonadUnliftPrim RW m => m a -> m b -> m a Source #
ubracket :: MonadUnliftPrim RW m => m a -> (a -> m b) -> (a -> m c) -> m c Source #
ubracket_ :: MonadUnliftPrim RW m => m a -> m b -> m c -> m c Source #
ubracketOnError :: MonadUnliftPrim RW m => m a -> (a -> m b) -> (a -> m c) -> m c Source #
mask :: forall a m s. MonadUnliftPrim s m => ((forall b. m b -> m b) -> m a) -> m a Source #
Mask all asychronous exceptions, but keep it interruptible, unless the inherited state
 was uninterruptible already, in which case this action has no affect. Same as
 mask, except that it is polymorphic in state token. Inside a state
 thread it cannot affect the result of computation, therefore it is safe to use it within
 ST monad.
Since: 0.3.0
mask_ :: forall a m s. MonadUnliftPrim s m => m a -> m a Source #
Mask all asychronous exceptions, but keep it interruptible, unless the inherited state
 was uninterruptible already, in which case this action has no affect. Same as
 mask_, except that it is polymorphic in state token. Inside a state
 thread it cannot affect the result of computation, therefore it is safe to use it within
 ST monad.
Since: 0.3.0
maskPrimBase_ :: forall a n m s. (MonadPrim s m, MonadPrimBase s n) => n a -> m a Source #
uninterruptibleMask :: forall a m s. MonadUnliftPrim s m => ((forall b. m b -> m b) -> m a) -> m a Source #
Mask all asychronous exceptions and mark it uninterruptible. Same as
 uninterruptibleMask, except that it is polymorphic in state
 token. Inside a state thread it cannot affect the result of computation, therefore it
 is safe to use it within ST monad.
Since: 0.3.0
uninterruptibleMask_ :: forall a m s. MonadUnliftPrim s m => m a -> m a Source #
Mask all async exceptions and make sure evaluation cannot be interrupted. It is
 polymorphic in the state token because it is perfectly safe to use with ST actions that
 don't perform any allocations. It doesn't have to be restricted to RealWorld because it
 has no impact on other threads and can't affect the result of computation, moreover pure
 functions that implement tight loops are already non-interruptible. In fact using this
 function is more dangerous in IO than it is in ST, because misuse can lead to deadlocks
 in a concurrent setting.
Since: 0.3.0
uninterruptibleMaskPrimBase_ :: forall a n m s. (MonadPrimBase s n, MonadPrim s m) => n a -> m a Source #
maskAsyncExceptions :: forall a m. MonadUnliftPrim RW m => m a -> m a Source #
A direct wrapper around maskAsyncExceptions# primop. This is different and more
 dangerous than mask_ because it can turn uninterrubtable state into interruptable.
unmaskAsyncExceptions :: forall a m. MonadUnliftPrim RW m => m a -> m a Source #
A direct wrapper around unmaskAsyncExceptions# primop.
maskUninterruptible :: forall a m. MonadUnliftPrim RW m => m a -> m a Source #
A direct wrapper around maskUninterruptible# primop.
data MaskingState #
Describes the behaviour of a thread when an asynchronous exception is received.
Constructors
| Unmasked | asynchronous exceptions are unmasked (the normal state)  | 
| MaskedInterruptible | the state during   | 
| MaskedUninterruptible | the state during   | 
Instances
| Eq MaskingState | Since: base-4.3.0.0  | 
Defined in GHC.IO  | |
| Show MaskingState | Since: base-4.3.0.0  | 
Defined in GHC.IO Methods showsPrec :: Int -> MaskingState -> ShowS # show :: MaskingState -> String # showList :: [MaskingState] -> ShowS #  | |
| NFData MaskingState | Since: deepseq-1.4.4.0  | 
Defined in Control.DeepSeq Methods rnf :: MaskingState -> () #  | |
getMaskingState :: MonadPrim RW m => m MaskingState Source #
Same as getMaskingState, but generalized to MonadPrim
Since: 0.3.0
Exceptions
class (Typeable e, Show e) => Exception e where #
Any type that you wish to throw or catch as an exception must be an
instance of the Exception class. The simplest case is a new exception
type directly below the root:
data MyException = ThisException | ThatException
    deriving Show
instance Exception MyExceptionThe default method definitions in the Exception class do what we need
in this case. You can now throw and catch ThisException and
ThatException as exceptions:
*Main> throw ThisException `catch` \e -> putStrLn ("Caught " ++ show (e :: MyException))
Caught ThisException
In more complicated examples, you may wish to define a whole hierarchy of exceptions:
---------------------------------------------------------------------
-- Make the root exception type for all the exceptions in a compiler
data SomeCompilerException = forall e . Exception e => SomeCompilerException e
instance Show SomeCompilerException where
    show (SomeCompilerException e) = show e
instance Exception SomeCompilerException
compilerExceptionToException :: Exception e => e -> SomeException
compilerExceptionToException = toException . SomeCompilerException
compilerExceptionFromException :: Exception e => SomeException -> Maybe e
compilerExceptionFromException x = do
    SomeCompilerException a <- fromException x
    cast a
---------------------------------------------------------------------
-- Make a subhierarchy for exceptions in the frontend of the compiler
data SomeFrontendException = forall e . Exception e => SomeFrontendException e
instance Show SomeFrontendException where
    show (SomeFrontendException e) = show e
instance Exception SomeFrontendException where
    toException = compilerExceptionToException
    fromException = compilerExceptionFromException
frontendExceptionToException :: Exception e => e -> SomeException
frontendExceptionToException = toException . SomeFrontendException
frontendExceptionFromException :: Exception e => SomeException -> Maybe e
frontendExceptionFromException x = do
    SomeFrontendException a <- fromException x
    cast a
---------------------------------------------------------------------
-- Make an exception type for a particular frontend compiler exception
data MismatchedParentheses = MismatchedParentheses
    deriving Show
instance Exception MismatchedParentheses where
    toException   = frontendExceptionToException
    fromException = frontendExceptionFromExceptionWe can now catch a MismatchedParentheses exception as
MismatchedParentheses, SomeFrontendException or
SomeCompilerException, but not other types, e.g. IOException:
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main> throw MismatchedParentheses `catch` \e -> putStrLn ("Caught " ++ show (e :: IOException))
*** Exception: MismatchedParentheses
Minimal complete definition
Nothing
Methods
toException :: e -> SomeException #
fromException :: SomeException -> Maybe e #
displayException :: e -> String #
Render this exception value in a human-friendly manner.
Default implementation: .show
Since: base-4.8.0.0
Instances
data SomeException #
The SomeException type is the root of the exception type hierarchy.
When an exception of type e is thrown, behind the scenes it is
encapsulated in a SomeException.
Instances
| Show SomeException | Since: base-3.0  | 
Defined in GHC.Exception.Type Methods showsPrec :: Int -> SomeException -> ShowS # show :: SomeException -> String # showList :: [SomeException] -> ShowS #  | |
| Exception SomeException | Since: base-3.0  | 
Defined in GHC.Exception.Type Methods toException :: SomeException -> SomeException # fromException :: SomeException -> Maybe SomeException # displayException :: SomeException -> String #  | |
Async exceptions
data AsyncException #
Asynchronous exceptions.
Constructors
| StackOverflow | The current thread's stack exceeded its limit. Since an exception has been raised, the thread's stack will certainly be below its limit again, but the programmer should take remedial action immediately.  | 
| HeapOverflow | The program's heap is reaching its limit, and the program should take action to reduce the amount of live data it has. Notes: 
  | 
| ThreadKilled | This exception is raised by another thread
 calling   | 
| UserInterrupt | This exception is raised by default in the main thread of the program when the user requests to terminate the program via the usual mechanism(s) (e.g. Control-C in the console).  | 
Instances
| Eq AsyncException | Since: base-4.2.0.0  | 
Defined in GHC.IO.Exception Methods (==) :: AsyncException -> AsyncException -> Bool # (/=) :: AsyncException -> AsyncException -> Bool #  | |
| Ord AsyncException | Since: base-4.2.0.0  | 
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 | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods showsPrec :: Int -> AsyncException -> ShowS # show :: AsyncException -> String # showList :: [AsyncException] -> ShowS #  | |
| Exception AsyncException | Since: base-4.7.0.0  | 
Defined in GHC.IO.Exception Methods toException :: AsyncException -> SomeException #  | |
data SomeAsyncException #
Superclass for asynchronous exceptions.
Since: base-4.7.0.0
Constructors
| Exception e => SomeAsyncException e | 
Instances
| Show SomeAsyncException | Since: base-4.7.0.0  | 
Defined in GHC.IO.Exception Methods showsPrec :: Int -> SomeAsyncException -> ShowS # show :: SomeAsyncException -> String # showList :: [SomeAsyncException] -> ShowS #  | |
| Exception SomeAsyncException | Since: base-4.7.0.0  | 
Defined in GHC.IO.Exception Methods toException :: SomeAsyncException -> SomeException # fromException :: SomeException -> Maybe SomeAsyncException #  | |
isSyncException :: Exception e => e -> Bool Source #
isAsyncException :: Exception e => e -> Bool Source #
asyncExceptionToException :: Exception e => e -> SomeException #
Since: base-4.7.0.0
asyncExceptionFromException :: Exception e => SomeException -> Maybe e #
Since: base-4.7.0.0
Standard exceptions
This is thrown when the user calls error. The first String is the
 argument given to error, second String is the location.
Constructors
| ErrorCallWithLocation String String | 
Instances
| Eq ErrorCall | Since: base-4.7.0.0  | 
| Ord ErrorCall | Since: base-4.7.0.0  | 
| Show ErrorCall | Since: base-4.0.0.0  | 
| Exception ErrorCall | Since: base-4.0.0.0  | 
Defined in GHC.Exception Methods toException :: ErrorCall -> SomeException # fromException :: SomeException -> Maybe ErrorCall # displayException :: ErrorCall -> String #  | |
data ArithException #
Arithmetic exceptions.
Constructors
| Overflow | |
| Underflow | |
| LossOfPrecision | |
| DivideByZero | |
| Denormal | |
| RatioZeroDenominator | Since: base-4.6.0.0  | 
Instances
| Eq ArithException | Since: base-3.0  | 
Defined in GHC.Exception.Type Methods (==) :: ArithException -> ArithException -> Bool # (/=) :: ArithException -> ArithException -> Bool #  | |
| Ord ArithException | Since: base-3.0  | 
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 | Since: base-4.0.0.0  | 
Defined in GHC.Exception.Type Methods showsPrec :: Int -> ArithException -> ShowS # show :: ArithException -> String # showList :: [ArithException] -> ShowS #  | |
| Exception ArithException | Since: base-4.0.0.0  | 
Defined in GHC.Exception.Type Methods toException :: ArithException -> SomeException #  | |
data ArrayException #
Exceptions generated by array operations
Constructors
| IndexOutOfBounds String | An attempt was made to index an array outside its declared bounds.  | 
| UndefinedElement String | An attempt was made to evaluate an element of an array that had not been initialized.  | 
Instances
| Eq ArrayException | Since: base-4.2.0.0  | 
Defined in GHC.IO.Exception Methods (==) :: ArrayException -> ArrayException -> Bool # (/=) :: ArrayException -> ArrayException -> Bool #  | |
| Ord ArrayException | Since: base-4.2.0.0  | 
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 | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods showsPrec :: Int -> ArrayException -> ShowS # show :: ArrayException -> String # showList :: [ArrayException] -> ShowS #  | |
| Exception ArrayException | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods toException :: ArrayException -> SomeException #  | |
newtype AssertionFailed #
Constructors
| AssertionFailed String | 
Instances
| Show AssertionFailed | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods showsPrec :: Int -> AssertionFailed -> ShowS # show :: AssertionFailed -> String # showList :: [AssertionFailed] -> ShowS #  | |
| Exception AssertionFailed | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods toException :: AssertionFailed -> SomeException #  | |
data IOException #
Exceptions that occur in the IO monad.
 An IOException records a more specific error type, a descriptive
 string and maybe the handle that was used when the error was
 flagged.
Instances
| Eq IOException | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception  | |
| Show IOException | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods showsPrec :: Int -> IOException -> ShowS # show :: IOException -> String # showList :: [IOException] -> ShowS #  | |
| Exception IOException | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods toException :: IOException -> SomeException # fromException :: SomeException -> Maybe IOException # displayException :: IOException -> String #  | |
data NonTermination #
Thrown when the runtime system detects that the computation is guaranteed not to terminate. Note that there is no guarantee that the runtime system will notice whether any given computation is guaranteed to terminate or not.
Constructors
| NonTermination | 
Instances
| Show NonTermination | Since: base-4.0  | 
Defined in Control.Exception.Base Methods showsPrec :: Int -> NonTermination -> ShowS # show :: NonTermination -> String # showList :: [NonTermination] -> ShowS #  | |
| Exception NonTermination | Since: base-4.0  | 
Defined in Control.Exception.Base Methods toException :: NonTermination -> SomeException #  | |
data NestedAtomically #
Thrown when the program attempts to call atomically, from the stm
 package, inside another call to atomically.
Constructors
| NestedAtomically | 
Instances
| Show NestedAtomically | Since: base-4.0  | 
Defined in Control.Exception.Base Methods showsPrec :: Int -> NestedAtomically -> ShowS # show :: NestedAtomically -> String # showList :: [NestedAtomically] -> ShowS #  | |
| Exception NestedAtomically | Since: base-4.0  | 
Defined in Control.Exception.Base Methods toException :: NestedAtomically -> SomeException #  | |
data BlockedIndefinitelyOnMVar #
The thread is blocked on an MVar, but there are no other references
 to the MVar so it can't ever continue.
Constructors
| BlockedIndefinitelyOnMVar | 
Instances
| Show BlockedIndefinitelyOnMVar | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods showsPrec :: Int -> BlockedIndefinitelyOnMVar -> ShowS # show :: BlockedIndefinitelyOnMVar -> String # showList :: [BlockedIndefinitelyOnMVar] -> ShowS #  | |
| Exception BlockedIndefinitelyOnMVar | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception  | |
data BlockedIndefinitelyOnSTM #
The thread is waiting to retry an STM transaction, but there are no
 other references to any TVars involved, so it can't ever continue.
Constructors
| BlockedIndefinitelyOnSTM | 
Instances
| Show BlockedIndefinitelyOnSTM | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods showsPrec :: Int -> BlockedIndefinitelyOnSTM -> ShowS # show :: BlockedIndefinitelyOnSTM -> String # showList :: [BlockedIndefinitelyOnSTM] -> ShowS #  | |
| Exception BlockedIndefinitelyOnSTM | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception  | |
data AllocationLimitExceeded #
This thread has exceeded its allocation limit.  See
 setAllocationCounter and
 enableAllocationLimit.
Since: base-4.8.0.0
Constructors
| AllocationLimitExceeded | 
Instances
| Show AllocationLimitExceeded | Since: base-4.7.1.0  | 
Defined in GHC.IO.Exception Methods showsPrec :: Int -> AllocationLimitExceeded -> ShowS # show :: AllocationLimitExceeded -> String # showList :: [AllocationLimitExceeded] -> ShowS #  | |
| Exception AllocationLimitExceeded | Since: base-4.8.0.0  | 
Defined in GHC.IO.Exception  | |
There are no runnable threads, so the program is deadlocked.
 The Deadlock exception is raised in the main thread only.
Constructors
| Deadlock | 
Instances
| Show Deadlock | Since: base-4.1.0.0  | 
| Exception Deadlock | Since: base-4.1.0.0  | 
Defined in GHC.IO.Exception Methods toException :: Deadlock -> SomeException # fromException :: SomeException -> Maybe Deadlock # displayException :: Deadlock -> String #  | |
CallStack
CallStacks are a lightweight method of obtaining a
 partial call-stack at any point in the program.
A function can request its call-site with the HasCallStack constraint.
 For example, we can define
putStrLnWithCallStack :: HasCallStack => String -> IO ()
as a variant of putStrLn that will get its call-site and print it,
 along with the string given as argument. We can access the
 call-stack inside putStrLnWithCallStack with callStack.
putStrLnWithCallStack :: HasCallStack => String -> IO () putStrLnWithCallStack msg = do putStrLn msg putStrLn (prettyCallStack callStack)
Thus, if we call putStrLnWithCallStack we will get a formatted call-stack
 alongside our string.
>>>putStrLnWithCallStack "hello"hello CallStack (from HasCallStack): putStrLnWithCallStack, called at <interactive>:2:1 in interactive:Ghci1
GHC solves HasCallStack constraints in three steps:
- If there is a 
CallStackin scope -- i.e. the enclosing function has aHasCallStackconstraint -- GHC will append the new call-site to the existingCallStack. - If there is no 
CallStackin scope -- e.g. in the GHCi session above -- and the enclosing definition does not have an explicit type signature, GHC will infer aHasCallStackconstraint for the enclosing definition (subject to the monomorphism restriction). - If there is no 
CallStackin scope and the enclosing definition has an explicit type signature, GHC will solve theHasCallStackconstraint for the singletonCallStackcontaining just the current call-site. 
CallStacks do not interact with the RTS and do not require compilation
 with -prof. On the other hand, as they are built up explicitly via the
 HasCallStack constraints, they will generally not contain as much
 information as the simulated call-stacks maintained by the RTS.
A CallStack is a [(String, SrcLoc)]. The String is the name of
 function that was called, the SrcLoc is the call-site. The list is
 ordered with the most recently called function at the head.
NOTE: The intrepid user may notice that HasCallStack is just an
 alias for an implicit parameter ?callStack :: CallStack. This is an
 implementation detail and should not be considered part of the
 CallStack API, we may decide to change the implementation in the
 future.
Since: base-4.8.1.0
type HasCallStack = ?callStack :: CallStack #
Request a CallStack.
NOTE: The implicit parameter ?callStack :: CallStack is an
 implementation detail and should not be considered part of the
 CallStack API, we may decide to change the implementation in the
 future.
Since: base-4.9.0.0
callStack :: HasCallStack => CallStack #
getCallStack :: CallStack -> [([Char], SrcLoc)] #
Extract a list of call-sites from the CallStack.
The list is ordered by most recent call.
Since: base-4.8.1.0
prettyCallStack :: CallStack -> String #
Pretty print a CallStack.
Since: base-4.9.0.0
A single location in the source code.
Since: base-4.8.1.0
Constructors
| SrcLoc | |
Fields 
  | |
prettySrcLoc :: SrcLoc -> String #
Pretty print a SrcLoc.
Since: base-4.9.0.0
module Control.Prim.Monad