Run the alloc action a -> m c with async exceptions disabled but keeping
blocking operations interruptible (see mask). Use the
output c as input to Unfold m c b to generate an output stream.
c is usually a resource under the state of monad m, e.g. a file
handle, that requires a cleanup after use. 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.
bracket only guarantees that the cleanup action runs, and it runs with
async exceptions enabled. The action must ensure that it can successfully
cleanup the resource in the face of sync or async exceptions.
When the stream ends normally or on a sync exception, cleanup action runs
immediately in the current thread context, whereas in other cases it runs in
the GC context, therefore, cleanup may be delayed until the GC gets to run.
See also: bracket_, gbracket
Inhibits stream fusion
Pre-release