handle -package:effectful-core
A version of
catch with the arguments swapped around; useful in
situations where the code for the handler is shorter. For example:
do handle (\NonTermination -> exitWith (ExitFailure 1)) $
...
The handle used by the action flagging this error.
Flipped version of
catch.
Generalized version of
handle.
Note, when the given computation throws an exception any monadic side
effects in
m will be discarded.
Logs an event if it meets the requirements given by the most recent
call to
setLevel.
When evaluating a stream if an exception occurs, stream evaluation
aborts and the specified exception handler is run with the exception
as argument.
Inhibits stream fusion
Traditional exception construct.
Typical usage in arrow notation:
proc p -> ...
body `handle` \ex -> handler
When evaluating a stream if an exception occurs, stream evaluation
aborts and the specified exception handler is run with the exception
as argument. The exception is caught and handled unless the handler
decides to rethrow it. Note that exception handling is not applied to
the stream returned by the exception handler.
Observes exceptions only in the stream generation, and not in stream
consumers.
Inhibits stream fusion
Like Streamly.Data.Stream.
handle but with one significant
difference, this function observes exceptions from the consumer of the
stream as well.
You can also convert
StreamK to
Stream and use exception
handling from
Stream module:
>>> handle f s = StreamK.fromStream $ Stream.handle (\e -> StreamK.toStream (f e)) (StreamK.toStream s)
When unfolding Unfold m a b if an exception e
occurs, unfold e using Unfold m e b.
Inhibits stream fusion
Pre-release
Generalized version of
handle.
handle, but with the argument order swapped
>>> runPureEff $ handle (pure . show) $ \e -> do
throw e 42
pure "No exception thrown"
"42"
Like
blob, but each
Log is rendered as text in its own
line.
If the given
Handle is associated to a TTY supporting ANSI
colors, and the given
LineRenderer supports rendering with
colors, and you ask for it, then you will get colorful output.