Run the alloc action
IO b with async exceptions disabled but
keeping blocking operations interruptible (see
mask). Use the
output
b of the IO action as input to the function
b
-> Stream m a to generate an output stream.
b is usually a resource under the IO monad, e.g. a file
handle, that requires a cleanup after use. The cleanup action
b
-> m c, runs whenever (1) the stream ends normally, (2) due to
a sync or async exception or, (3) if it gets garbage collected after a
partial lazy evaluation. The exception is not caught, it is rethrown.
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_
Inhibits stream fusion