bracket<A, B> function

IO<B> Function(IO<A> ) bracket<A, B>({
  1. required IO<void> release(
    1. A
    ),
  2. required IO<B> use(
    1. A
    ),
})

Implementation

IO<B> Function(IO<A>) bracket<A, B>({
  required IO<void> Function(A) release,
  required IO<B> Function(A) use,
}) =>
    (acquire) => () {
          final resource = acquire();
          try {
            return use(resource)();
          } finally {
            release(resource)();
          }
        };