bracket<ENV, A, B> function

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

Implementation

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