Bi      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh0(C) Edward Kmett 2013-2015, (c) Google Inc. 2012 BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Trustworthy;=>?CFKQTV{$Generalized version of iA class for monads which provide for the ability to account for all possible exit points from a computation, and to mask asynchronous exceptions. Continuation-based monads are invalid instances of this class.Note that this package does provide a  MonadMask instance for CatchT. This instance is onlyU valid if the base monad provides no ability to provide multiple exit. For example, IO or Either$ would be invalid base monads, but Reader or State would be acceptable.4Instances should ensure that, in the following code:  f `finally` g The action g, is called regardless of what occurs within f, including async exceptions. Runs an action with asynchronous exceptions disabled. The action is provided a method for restoring the async. environment to what it was at the   call. See Control.Exception's j. Like  8, but the masked computation is not interruptible (see Control.Exception's k. WARNING: Only use if you need to mask exceptions around an interruptible operation AND you can guarantee the interruptible operation will only block for a short period of time. Otherwise you render the program/thread unresponsive and/or unkillable.  A generalized version of the standard bracket function which allows distinguishing different exit cases. Instead of providing it a single release action, this function takes two different actions: one for the case of a successful run of the inner function, and one in the case of an exception. The former function is provided the acquired value, while the exception release function is provided both the acquired value and the exception that was thrown. The result values of both of these functions are ignored.NOTEg This method was added in version 0.9.0 of this library. Previously, implementation of functions like  and !" in this module were based on the   and  F functions only, disallowing some classes of tranformers from having  MonadMask8 instances (notably multi-exit-point transformers like l{). If you are a library author, you'll now need to provide an implementation for this method. As two examples, here is a ReaderT implementation: generalBracket acquire release cleanup use = ReaderT $ r -> generalBracket (runReaderT acquire r) (resource -> runReaderT (release resource) r) (resource e -> runReaderT (cleanup resource e) r) (resource -> runReaderT (use resource) r) ,This implementation reuses the base monad's generalBracket, and simply uses the ReaderT" environment to run the relevant acquire, release, cleanup (for exceptions), and useA actions. A more complicated example is the implementation for ExceptT, which must implement ExceptT's short-circuit logic itself: generalBracket acquire release cleanup use = ExceptT $ generalBracket (runExceptT acquire) (eresource -> case eresource of Left _ -> return () Right resource -> runExceptT (release resource) >> return ()) (eresource e -> case eresource of Left _ -> return () Right resource -> runExceptT (cleanup resource e) >> return ()) (either (return . Left) (runExceptT . use)) EIn this implementation, we need to deal with the potential that the acquire action returned a Left# (as opposed to succeeding with a Right or throwing an exception via throwM%), and therefore have to handle the Left case explicitly when provide release, cleanup, and use0 actions to the base monad's implementation of generalBracket.+You should ensure that in all cases of the acquire- action completing successfully, either the release or cleanup3 actions are called, regardless of what occurs in use. gA class for monads which allow exceptions to be caught, in particular exceptions which were thrown by .(Instances should obey the following law: catch (throwM e) f = f e1Note that the ability to catch an exception does not guarantee that we can deal with all possible exit points from a computation. Some monads, such as continuation-based stacks, allow for more than just a success/failure strategy, and therefore catch cannotC be used by those monads to properly implement a function such as finally. For more information, see . Provide a handler for exceptions thrown during execution of the first action. Note that type of the type of the argument to the handler will constrain which exceptions are caught. See Control.Exception's m.5A class for monads in which exceptions may be thrown.(Instances should obey the following law: throwM e >> x = throwM eZIn other words, throwing an exception short-circuits the rest of the monadic computation.PThrow an exception. Note that this throws when this action is run in the monad m5, not when it is applied. It is a generalization of Control.Exception's n.Should satisfy the law: throwM e >> f = throwM eLike  , but does not pass a restore action to the argument.Like  , but does not pass a restore action to the argument.lCatches all exceptions, and somewhat defeats the purpose of the extensible exception system. Use sparingly. Catch all o (eqv.  IOExceptionA) exceptions. Still somewhat too general, but better than using . See ' for an easy way of catching specific os based on the predicates in System.IO.Error.aCatch exceptions only if they pass some predicate. Often useful with the predicates for testing o values in System.IO.Error.MA more generalized way of determining which exceptions to catch at run time.Flipped  . See Control.Exception's p.Flipped Flipped Flipped Flipped . See Control.Exception's q. Similar to  , but returns an r result. See Control.Exception's . A variant of O that takes an exception predicate to select which exceptions are caught. See Control.Exception's s+Catches different sorts of exceptions. See Control.Exception's toRun an action only if an exception is thrown in the main action. The exception is not caught, simply rethrown. Generalized abstracted pattern of safe resource acquisition and release in the face of exceptions. The first action "acquires" some value, which is "released" by the second action at the end. The third action "uses" the value and its result is the result of the .cIf an exception occurs during the use, the release still happens before the exception is rethrown.=Note that this is essentially a type-specialized version of  J. This function has a more common signature (matching the signature from Control.Exception6), and is often more convenient to use. By contrast,  D is more expressive, allowing us to implement other functions like ".  Version of A without any value being passed to the second and third actions.!TPerform an action with a finalizer action that is run, even if an exception occurs."Like e, but only performs the final action if there was an exception raised by the in-between computation.$&Throws exceptions into the base monad.%&Throws exceptions into the base monad.&&Throws exceptions into the base monad.6'Catches exceptions from the base monad.7'Catches exceptions from the base monad.8'Catches exceptions from the base monad.BO acquire some resourcerelease, no exception thrown>release, some exception thrown; the exception will be rethrown)inner action to perform with the resource#  !"#   !"  0(C) Edward Kmett 2013-2015, (c) Google Inc. 2012 BSD-style (see the file LICENSE)Edward Kmett <ekmett@gmail.com> experimental non-portable Trustworthy ;=>?CKQVsSAdd  handling abilities to a u. This should never be used in combination with v . Think of S\ as an alternative base monad for use with mocking code that solely throws exceptions via . Note: that v0 monad has these abilities already, so stacking SD on top of it does not add any value and can possibly be confusing:I(error "Hello!" :: IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)Hello!\runCatchT $ (error "Hello!" :: CatchT IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)*** Exception: Hello!irunCatchT $ (throwM (ErrorCall "Hello!") :: CatchT IO ()) `catch` (\(e :: ErrorCall) -> liftIO $ print e)Hello!W7Map the unwrapped computation using the given function. U (W f m) = f (U m)\SNote: This instance is only valid if the underlying monad has a single exit point!)  !"RSTUVWSTURVWSTUw       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWWXYZ[\]^_`abcdefghijk llmnollpqrsstus !vwxyz{'exceptions-0.9.0-4SAaUS2AHfu3bIUuexx1a0Control.Monad.CatchControl.Monad.Catch.PureControl.Exceptiontrybase GHC.Exception SomeExceptiondisplayException fromException toException ExceptionHandler MonadMaskmaskuninterruptibleMaskgeneralBracket MonadCatchcatch MonadThrowthrowMmask_uninterruptibleMask_catchAll catchIOErrorcatchIf catchJusthandle handleIOError handleAllhandleIf handleJusttryJustcatches onExceptionbracketbracket_finallybracketOnError$fMonadThrowContT$fMonadThrowExceptT$fMonadThrowErrorT$fMonadThrowMaybeT$fMonadThrowListT$fMonadThrowRWST$fMonadThrowRWST0$fMonadThrowWriterT$fMonadThrowWriterT0$fMonadThrowReaderT$fMonadThrowStateT$fMonadThrowStateT0$fMonadThrowIdentityT$fMonadThrowEither$fMonadThrowSTM$fMonadThrowIO $fMonadThrowQ$fMonadThrowMaybe$fMonadThrow[]$fMonadCatchExceptT$fMonadCatchErrorT$fMonadCatchMaybeT$fMonadCatchListT$fMonadCatchRWST$fMonadCatchRWST0$fMonadCatchWriterT$fMonadCatchWriterT0$fMonadCatchReaderT$fMonadCatchStateT$fMonadCatchStateT0$fMonadCatchIdentityT$fMonadCatchEither$fMonadCatchSTM$fMonadCatchIO$fMonadMaskExceptT$fMonadMaskErrorT$fMonadMaskRWST$fMonadMaskRWST0$fMonadMaskWriterT$fMonadMaskWriterT0$fMonadMaskReaderT$fMonadMaskStateT$fMonadMaskStateT0$fMonadMaskIdentityT$fMonadMaskEither $fMonadMaskIO$fFunctorHandlerCatchCatchT runCatchTrunCatch mapCatchT$fMonadRWSrwsCatchT$fMonadWriterwCatchT$fMonadReadereCatchT$fMonadStatesCatchT$fMonadMaskCatchT$fMonadCatchCatchT$fMonadThrowCatchT$fMonadIOCatchT$fMonadTransCatchT$fMonadPlusCatchT$fAlternativeCatchT$fTraversableCatchT$fFoldableCatchT$fMonadFixCatchT $fMonadCatchT$fApplicativeCatchT$fFunctorCatchTGHC.IOtransformers-0.5.2.0Control.Monad.Trans.ExceptExceptTthrowIOGHC.IO.ExceptionIOErrorControl.Exception.Base Data.EitherEitherGHC.BaseMonadghc-prim GHC.TypesIO