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

:: (MonadIO m, MonadBaseControl IO m) 
=> m c

before

-> (forall s. m s -> m (Either e s))

try (exception handling)

-> (c -> m d)

after, on normal stop or GC

-> (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).

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 :: (MonadIO m, MonadBaseControl IO 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 -> 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.