lambdabot-utils-4.2: Utility libraries for the advanced IRC bot, LambdabotSource codeContentsIndex
Error utilities
catchErrorJust :: MonadError e m => (e -> Maybe b) -> m a -> (b -> m a) -> m a
handleError :: MonadError e m => (e -> m a) -> m a -> m a
handleErrorJust :: MonadError e m => (e -> Maybe b) -> (b -> m a) -> m a -> m a
tryError :: MonadError e m => m a -> m (Either e a)
tryErrorJust :: MonadError e m => (e -> Maybe b) -> m a -> m (Either b a)
finallyError :: MonadError e m => m a -> m b -> m a
bracketError :: MonadError e m => m a -> (a -> m b) -> (a -> m c) -> m c
bracketError_ :: MonadError e m => m a -> m b -> m c -> m c
:: MonadError e m
=> e -> Maybe bDecider function
-> m aMonad
-> b -> m aHandler function
-> m aResult: A monadic operation on type a
catchErrorJust is an error catcher for the Maybe type. As input is given a deciding function, a monad and a handler. When an error is caught, the decider is executed to decide if the error should be handled or not. Then the handler is eventually called to handle the error.
:: MonadError e m
=> e -> m aError handler
-> m aMonad
-> m aResulting monad
handleError is the flipped version of catchError.
:: MonadError e m
=> e -> Maybe bDecider
-> b -> m aHandler
-> m aMonad
-> m aResulting Monad
handleErrorJust is the flipped version of catchErrorJust.
:: MonadError e m
=> m aMonad to operate on
-> m (Either e a)Returns: Explicit Either type
tryError uses Either to explicitly define the outcome of a monadic operation. An error is caught and placed into Right, whereas successful operation is placed into Left.
:: MonadError e m
=> e -> Maybe bDecider
-> m aMonad
-> m (Either b a)Returns: Explicit Either type
tryErrorJust is the catchErrorJust version of tryError given is a decider guarding whether or not the error should be handled. The handler will always Right and no errors are Left'ed through. If the decider returns Nothing, the error will be thrown further up.
:: MonadError e m
=> m aMonadic operation
-> m bGuard
-> m aReturns: A new monad.
finallyError is a monadic version of the classic UNWIND-PROTECT of lisp fame. Given parameters m and after (both monads) we proceed to work on m. If an error is caught, we execute the out-guard, after, before rethrowing the error. If m does not fail, after is executed and the value of m is returned.
:: MonadError e m
=> m aBefore (in-guard) monad
-> a -> m bAfter (out-guard) operation. Fed output of before
-> a -> m cMonad to work on. Fed with output of before
-> m cResulting monad.
bracketError is the monadic version of DYNAMIC-WIND from Scheme fame. Parameters are: before, after and m. before is the in-guard being executed before m. after is the out-guard and protects fails of the m. In the Haskell world, this scheme is called a bracket and is often seen employed to manage resources.
:: MonadError e m
=> m aBefore (in-guard)
-> m bAfter (out-guard)
-> m cMonad to work on
-> m cResulting monad
bracketError_ is the non-bound version of bracketError. The naming scheme follows usual Haskell convention.
Produced by Haddock version 2.4.2