arrow-fx / arrow.fx.typeclasses / Bracket
interface ~~Bracket~~<F, E> : MonadError<F, E>
Deprecated: The IO datatype and it’s related type classes will disappear in Arrow 0.13.0. All useful operations are offered directly over suspend functions by Arrow Fx Coroutines. https://arrow-kt.io/docs/fx/async/
Extension of MonadError exposing the bracket operation, a generalized abstracted pattern of safe resource acquisition and release in the face of errors or interruption.
Define The functions receiver here (Kind<F, A>) would stand for the “acquireParam”, and stands for an action that “acquires” some expensive resource, that needs to be used and then discarded.
Define use is the action that uses the newly allocated resource and that will provide the final result.
bracket | Meant for specifying tasks with safe resource acquisition and release in the face of errors and interruption. It would be the the equivalent of try/catch/finally statements in mainstream imperative languages for resource acquisition and release.open fun <A, B> Kind<F, A>.bracket(release: (A) -> Kind<F, Unit >, use: (A) -> Kind<F, B>): Kind<F, B> |
bracketCase | A way to safely acquire a resource and release in the face of errors and cancellation. It uses ExitCase to distinguish between different exit cases when releasing the acquired resource.abstract fun <A, B> Kind<F, A>.bracketCase(release: (A, ExitCase <E>) -> Kind<F, Unit >, use: (A) -> Kind<F, B>): Kind<F, B> |
guarantee | Executes the given finalizer when the source is finished, either in success or in error, or if cancelled.open fun <A> Kind<F, A>.guarantee(finalizer: Kind<F, Unit >): Kind<F, A> |
guaranteeCase | Executes the given finalizer when the source is finished, either in success or in error, or if cancelled, allowing for differentiating between exit conditions. That’s thanks to the ExitCase argument of the finalizer.open fun <A> Kind<F, A>.guaranteeCase(finalizer: ( ExitCase <E>) -> Kind<F, Unit >): Kind<F, A> |
onCancel | Executes the given finalizer when the source is cancelled, allowing registering a cancellation token.open fun <A> Kind<F, A>.onCancel(finalizer: Kind<F, Unit >): Kind<F, A> |
onError | Executes the given finalizer with the given error when the source is finished in error.open fun <A> Kind<F, A>.onError(finalizer: (E) -> Kind<F, Unit >): Kind<F, A> |
uncancelable | open fun <A> Kind<F, A>.~~uncancelable~~(): Kind<F, A> |
uncancellable | Meant for ensuring a given task continues execution even when interrupted.open fun <A> Kind<F, A>.uncancellable(): Kind<F, A> |
IOBracket | interface ~~IOBracket~~ : Bracket < ForIO , Throwable >, IOMonadThrow |
MonadDefer | The context required to defer evaluating a safe computation.interface ~~MonadDefer~~<F> : MonadThrow<F>, Bracket <F, Throwable > |
Do you like Arrow?
✖