streamly-0.8.2: Dataflow programming and declarative concurrency
Copyright(c) 2020 Composewell Technologies and Contributors
LicenseBSD-3-Clause
Maintainerstreamly@composewell.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.Data.Stream.StreamD.Exception

Description

 
Synopsis

Documentation

gbracket_ Source #

Arguments

:: 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

gbracket Source #

Arguments

:: MonadRunInIO 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

before :: Monad m => m b -> Stream m a -> Stream m a Source #

See before.

after_ :: Monad m => m b -> Stream m a -> Stream m a Source #

See after_.

after :: MonadRunInIO m => m b -> Stream m a -> Stream m a Source #

See after.

bracket_ :: MonadCatch m => m b -> (b -> m c) -> (b -> Stream m a) -> Stream m a Source #

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 #

finally_ :: MonadCatch m => m b -> Stream m a -> Stream m a Source #

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.

handle :: (MonadCatch m, Exception e) => (e -> Stream m a) -> Stream m a -> Stream m a Source #

See handle.

retry Source #

Arguments

:: forall e m a. (Exception e, Ord e, MonadCatch m) 
=> Map e Int

map from exception to retry count

-> (e -> Stream m a)

default handler for those exceptions that are not in the map

-> Stream m a 
-> Stream m a 

See retry