@@ -257,6 +257,9 @@ afterIO action (Stream step state) = Stream step' Nothing
257-- | Run the action @m b@ if the stream evaluation is aborted due to an
257-- | Run the action @m b@ if the stream evaluation is aborted due to an
258-- exception. The exception is not caught, simply rethrown.
258-- exception. The exception is not caught, simply rethrown.
260+-- Observes exceptions only in the stream generation, and not in stream
260-- /Inhibits stream fusion/
263-- /Inhibits stream fusion/
262{-# INLINE_NORMAL onException #-}
265{-# INLINE_NORMAL onException #-}
@@ -320,6 +323,8 @@ bracketUnsafe bef aft =
320-- stream is abandoned @onGC@ is executed, if the stream encounters an
323-- stream is abandoned @onGC@ is executed, if the stream encounters an
321-- exception @onException@ is executed.
324-- exception @onException@ is executed.
326+-- The exception is not caught, it is rethrown.
323-- /Inhibits stream fusion/
328-- /Inhibits stream fusion/
325-- /Pre-release/
330-- /Pre-release/
@@ -335,18 +340,20 @@ bracketIO3 bef aft onExc onGC =
338− (\a (e :: SomeException) _ -> onExc a >> return (nilM (MC.throwM e)))
343+ (\a (e :: SomeException) _ -> onExc a >> MC.throwM e)
340 (inline MC.try)
345 (inline MC.try)
342-- | Run the alloc action @IO b@ with async exceptions disabled but keeping
347-- | Run the alloc action @IO b@ with async exceptions disabled but keeping
343-- blocking operations interruptible (see 'Control.Exception.mask'). Use the
348-- blocking operations interruptible (see 'Control.Exception.mask'). Use the
349+-- output @b@ of the IO action as input to the function @b -> Stream m a@ to
344−-- output @b@ as input to @b -> Stream m a@ to generate an output stream.
350+-- generate an output stream.
346-- @b@ is usually a resource under the IO monad, e.g. a file handle, that
352-- @b@ is usually a resource under the IO monad, e.g. a file handle, that
347-- requires a cleanup after use. The cleanup action @b -> IO c@, runs whenever
353-- requires a cleanup after use. The cleanup action @b -> IO c@, runs whenever
348−-- the stream ends normally, due to a sync or async exception or if it gets
354+-- (1) the stream ends normally, (2) due to a sync or async exception or, (3)
349−-- garbage collected after a partial lazy evaluation.
355+-- if it gets garbage collected after a partial lazy evaluation. The exception
356+-- is not caught, it is rethrown.
351-- 'bracketIO' only guarantees that the cleanup action runs, and it runs with
358-- 'bracketIO' only guarantees that the cleanup action runs, and it runs with
352-- async exceptions enabled. The action must ensure that it can successfully
359-- async exceptions enabled. The action must ensure that it can successfully
@@ -355,6 +362,12 @@ bracketIO3 bef aft onExc onGC =
355-- When the stream ends normally or on a sync exception, cleanup action runs
362-- When the stream ends normally or on a sync exception, cleanup action runs
356-- immediately in the current thread context, whereas in other cases it runs in
363-- immediately in the current thread context, whereas in other cases it runs in
357-- the GC context, therefore, cleanup may be delayed until the GC gets to run.
364-- the GC context, therefore, cleanup may be delayed until the GC gets to run.
365+-- An example where GC based cleanup happens is when a stream is being folded
366+-- but the fold terminates without draining the entire stream or if the
367+-- consumer of the stream encounters an exception.
369+-- Observes exceptions only in the stream generation, and not in stream
359-- /See also: 'bracketUnsafe'/
372-- /See also: 'bracketUnsafe'/
@@ -443,6 +456,12 @@ ghandle f stream =
444-- | When evaluating a stream if an exception occurs, stream evaluation aborts
457-- | When evaluating a stream if an exception occurs, stream evaluation aborts
445-- and the specified exception handler is run with the exception as argument.
458-- and the specified exception handler is run with the exception as argument.
459+-- The exception is caught and handled unless the handler decides to rethrow
460+-- it. Note that exception handling is not applied to the stream returned by
461+-- the exception handler.
463+-- Observes exceptions only in the stream generation, and not in stream
447-- /Inhibits stream fusion/
466-- /Inhibits stream fusion/