Bracket
public protocol Bracket : MonadError
Bracket models a generalized abstracted pattern of safe resource acquisition and release in the face of errors or interruptions.
-
A way to safely acquire a resource and release in the face of errors and cancellations. It uses
ExitCaseto distinguish between different exit cases when releasing the acquired resource.Declaration
Parameters
faComputation to describe the acquisition of the resource.
releaseFunction to release the acquired resource.
useFunction to use the acquired resource.
Return Value
Computation describing the result of using the resource.
-
bracket(acquire:release:use:)Extension methodA way to safely acquire a resource and release in the face of errors and cancellations. It uses
ExitCaseto distinguish between different exit cases when releasing the acquired resource.Declaration
Parameters
faComputation to describe the acquisition of the resource.
releaseFunction to release the acquired resource, ignoring the outcome of the release of the resource.
useFunction to use the acquired resource.
Return Value
Computation describing the result of using the resource.
-
uncancelable(_:)Extension method -
guarantee(_:finalizer:)Extension methodExecutes the given finalizer when the source is finished, either in success, error or cancelation.
Declaration
Parameters
faComputation describing the acquisition of the resource.
finalizerFinalizer function to be invoked when the resource is released.
Return Value
A computation describing the resouce that will invoke the finalizer when it is released.
-
guaranteeCase(_:finalizer:)Extension methodExecutes the given finalizer when the source is finished, either in success, error or cancelation, alowing to differentiate between exit conditions.
Declaration
Parameters
faComputation describing the acquisition of the resource.
finalizerFinalizer function to be invoked when the resource is released, distinguishing the exit case.
Return Value
A computation describing the resource that will invoke the finalizer when it is released.
Install in Dash
Bracket Protocol Reference