@@ -257,6 +257,9 @@ afterIO action (Stream step state) = Stream step' Nothing
257257-- | Run the action @m b@ if the stream evaluation is aborted due to an
258258-- exception. The exception is not caught, simply rethrown.
259259--
260+-- Observes exceptions only in the stream generation, and not in stream
261+-- consumers.
262+--
260263-- /Inhibits stream fusion/
261264--
262265{-# INLINE_NORMAL onException #-}
@@ -320,6 +323,8 @@ bracketUnsafe bef aft =
320323-- stream is abandoned @onGC@ is executed, if the stream encounters an
321324-- exception @onException@ is executed.
322325--
326+-- The exception is not caught, it is rethrown.
327+--
323328-- /Inhibits stream fusion/
324329--
325330-- /Pre-release/
@@ -335,18 +340,20 @@ bracketIO3 bef aft onExc onGC =
335340 gbracket
336341 bef
337342 aft
338− (\a (e :: SomeException) _ -> onExc a >> return (nilM (MC.throwM e)))
343+ (\a (e :: SomeException) _ -> onExc a >> MC.throwM e)
339344 onGC
340345 (inline MC.try)
341346
342347-- | Run the alloc action @IO b@ with async exceptions disabled but keeping
343348-- blocking operations interruptible (see 'Control.Exception.mask'). Use the
344−-- output @b@ as input to @b -> Stream m a@ to generate an output stream.
349+-- output @b@ of the IO action as input to the function @b -> Stream m a@ to
350+-- generate an output stream.
345351--
346352-- @b@ is usually a resource under the IO monad, e.g. a file handle, that
347353-- 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
349−-- garbage collected after a partial lazy evaluation.
354+-- (1) the stream ends normally, (2) due to a sync or async exception or, (3)
355+-- if it gets garbage collected after a partial lazy evaluation. The exception
356+-- is not caught, it is rethrown.
350357--
351358-- 'bracketIO' only guarantees that the cleanup action runs, and it runs with
352359-- async exceptions enabled. The action must ensure that it can successfully
@@ -355,6 +362,12 @@ bracketIO3 bef aft onExc onGC =
355362-- When the stream ends normally or on a sync exception, cleanup action runs
356363-- immediately in the current thread context, whereas in other cases it runs in
357364-- 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.
368+--
369+-- Observes exceptions only in the stream generation, and not in stream
370+-- consumers.
358371--
359372-- /See also: 'bracketUnsafe'/
360373--
@@ -443,6 +456,12 @@ ghandle f stream =
443456
444457-- | When evaluating a stream if an exception occurs, stream evaluation aborts
445458-- 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.
462+--
463+-- Observes exceptions only in the stream generation, and not in stream
464+-- consumers.
446465--
447466-- /Inhibits stream fusion/
448467--