@Test public void use(@Mock Consumer1<String> release) { Resource<F, String> resource = makeResource(pure("hola"), release); Kind<F, String> use = resource.use(string -> pure(string.toUpperCase())); assertEquals("HOLA", run(use)); verify(release).accept("hola"); }
public <R> Kind<F, R> use(Function1<? super T, ? extends Kind<F, ? extends R>> use) { return monad.bracket(resource, t -> use.apply(t.get1()), Resource::release); }
Resource implements ResourceOf<F, T> { public <R> Kind<F, R> use(Function1<? super T, ? extends Kind<F, ? extends R>> use) { return monad.bracket(resource, t -> use.apply(t.get1()), Resource::release); } }
Resource implements ResourceOf<F, T> { public <R> Kind<F, R> use(Function1<? super T, ? extends Kind<F, ? extends R>> use) { return monad.bracket(resource, t -> use.apply(t.get1()), Resource::release); } protected  Resource(MonadDefer<F> monad, Kind<F, Tuple2<T, Consumer1<? super T>>> resource); }
Resource implements ResourceOf<F, T> { public <R> Kind<F, R> use(Function1<? super T, ? extends Kind<F, ? extends R>> use) { return monad.bracket(resource, t -> use.apply(t.get1()), Resource::release); } protected  Resource(MonadDefer<F> monad, Kind<F, Tuple2<T, Consumer1<? super T>>> resource); Resource<F, R> map(Function1<? super T, ? extends R> mapper); Resource<F, R> flatMap(Function1<? super T, ? extends Resource<F, ? extends R>> mapper); Kind<F, R> use(Function1<? super T, ? extends Kind<F, ? extends R>> use); Resource<F, Tuple2<T, R>> combine(Resource<F, ? extends R> other); static Resource<F, T> pure(
      MonadDefer<F> monad, Kind<F, ? extends T> acquire); static Resource<F, T> from(
      MonadDefer<F> monad, Kind<F, ? extends T> acquire, Consumer1<? super T> release); static Resource<F, T> from(
      MonadDefer<F> monad, Kind<F, ? extends T> acquire); }
Resource implements ResourceOf<F, T> { public <R> Kind<F, R> use(Function1<? super T, ? extends Kind<F, ? extends R>> use) { return monad.bracket(resource, t -> use.apply(t.get1()), Resource::release); } protected  Resource(MonadDefer<F> monad, Kind<F, Tuple2<T, Consumer1<? super T>>> resource); Resource<F, R> map(Function1<? super T, ? extends R> mapper); Resource<F, R> flatMap(Function1<? super T, ? extends Resource<F, ? extends R>> mapper); Kind<F, R> use(Function1<? super T, ? extends Kind<F, ? extends R>> use); Resource<F, Tuple2<T, R>> combine(Resource<F, ? extends R> other); static Resource<F, T> pure(
      MonadDefer<F> monad, Kind<F, ? extends T> acquire); static Resource<F, T> from(
      MonadDefer<F> monad, Kind<F, ? extends T> acquire, Consumer1<? super T> release); static Resource<F, T> from(
      MonadDefer<F> monad, Kind<F, ? extends T> acquire);  }