Copyright | (c) 2020 Composewell Technologies and Contributors |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- gbracket_ :: Monad m => m c -> (forall s. m s -> m (Either e s)) -> (c -> m d) -> (c -> e -> Stream m b -> Stream m b) -> (c -> Stream m b) -> Stream m b
- gbracket :: (MonadIO m, MonadBaseControl IO m) => m c -> (forall s. m s -> m (Either e s)) -> (c -> m d1) -> (c -> m d2) -> (c -> e -> Stream m b -> m (Stream m b)) -> (c -> Stream m b) -> Stream m b
- before :: Monad m => m b -> Stream m a -> Stream m a
- after_ :: Monad m => m b -> Stream m a -> Stream m a
- after :: (MonadIO m, MonadBaseControl IO m) => m b -> Stream m a -> Stream m a
- bracket_ :: MonadCatch m => m b -> (b -> m c) -> (b -> Stream m a) -> Stream m a
- bracket' :: (MonadAsync m, MonadCatch m) => m b -> (b -> m c) -> (b -> m d) -> (b -> m e) -> (b -> Stream m a) -> Stream m a
- onException :: MonadCatch m => m b -> Stream m a -> Stream m a
- finally_ :: MonadCatch m => m b -> Stream m a -> Stream m a
- finally :: (MonadAsync m, MonadCatch m) => m b -> Stream m a -> Stream m a
- ghandle :: (MonadCatch m, Exception e) => (e -> Stream m a -> Stream m a) -> Stream m a -> Stream m a
- handle :: (MonadCatch m, Exception e) => (e -> Stream m a) -> Stream m a -> Stream m a
- retry :: forall e m a. (Exception e, Ord e, MonadCatch m) => Map e Int -> (e -> Stream m a) -> Stream m a -> Stream m a
Documentation
:: Monad m | |
=> m c | before |
-> (forall s. m s -> m (Either e s)) | try (exception handling) |
-> (c -> m d) | after, on normal stop |
-> (c -> e -> Stream m b -> Stream m b) | on exception |
-> (c -> Stream m b) | stream generator |
-> Stream m b |
Like gbracket
but with following differences:
- alloc action
m c
runs with async exceptions enabled - cleanup action
c -> m d
won't run if the stream is garbage collected after partial evaluation. - does not require a
MonadAsync
constraint.
Inhibits stream fusion
Pre-release
:: (MonadIO m, MonadBaseControl IO m) | |
=> m c | before |
-> (forall s. m s -> m (Either e s)) | try (exception handling) |
-> (c -> m d1) | on normal stop |
-> (c -> m d2) | on GC without normal stop or exception |
-> (c -> e -> Stream m b -> m (Stream m b)) | on exception |
-> (c -> Stream m b) | stream generator |
-> Stream m b |
Run the alloc action m c
with async exceptions disabled but keeping
blocking operations interruptible (see mask
). Use the
output c
as input to c -> Stream m b
to generate an output stream. When
generating the stream use the supplied try
operation forall s. m s -> m
(Either e s)
to catch synchronous exceptions. If an exception occurs run
the exception handler c -> e -> Stream m b -> m (Stream m b)
. Note that
gbracket
does not rethrow the exception, it has to be done by the
exception handler if desired.
The cleanup action c -> m d
, runs whenever the stream ends normally, due
to a sync or async exception or if it gets garbage collected after a partial
lazy evaluation. See bracket
for the semantics of the cleanup action.
gbracket
can express all other exception handling combinators.
Inhibits stream fusion
Pre-release
bracket_ :: MonadCatch m => m b -> (b -> m c) -> (b -> Stream m a) -> Stream m a Source #
See bracket_
.
bracket' :: (MonadAsync m, MonadCatch m) => m b -> (b -> m c) -> (b -> m d) -> (b -> m e) -> (b -> Stream m a) -> Stream m a Source #
See bracket
.
onException :: MonadCatch m => m b -> Stream m a -> Stream m a Source #
See onException
.
finally :: (MonadAsync m, MonadCatch m) => m b -> Stream m a -> Stream m a Source #
See finally
.
finally action xs = after action $ onException action xs
ghandle :: (MonadCatch m, Exception e) => (e -> Stream m a -> Stream m a) -> Stream m a -> Stream m a Source #
See ghandle
.