@Test public void combine(@Mock Consumer1<String> release1, @Mock Consumer1<Integer> release2) { Resource<F, String> res1 = makeResource(pure("hola"), release1); Resource<F, Integer> res2 = makeResource(pure(5), release2); Resource<F, Tuple2<String, Integer>> combine = res1.combine(res2); Kind<F, String> use = combine.use(tuple -> later(tuple::toString)); assertEquals("Tuple2(hola, 5)", run(use)); verify(release1).accept("hola"); verify(release2).accept(5); }
public <R> Resource<F, Tuple2<T, R>> combine(Resource<F, ? extends R> other) { return new Resource<>(monad, monad.bracket(resource, t -> monad.bracket(other.resource, r -> monad.pure(Tuple.of(Tuple.of(t.get1(), r.get1()), noop())), Resource::release), Resource::release)); }
Resource implements ResourceOf<F, T> { public <R> Resource<F, Tuple2<T, R>> combine(Resource<F, ? extends R> other) { return new Resource<>(monad, monad.bracket(resource, t -> monad.bracket(other.resource, r -> monad.pure(Tuple.of(Tuple.of(t.get1(), r.get1()), noop())), Resource::release), Resource::release)); } }
Resource implements ResourceOf<F, T> { public <R> Resource<F, Tuple2<T, R>> combine(Resource<F, ? extends R> other) { return new Resource<>(monad, monad.bracket(resource, t -> monad.bracket(other.resource, r -> monad.pure(Tuple.of(Tuple.of(t.get1(), r.get1()), noop())), Resource::release), Resource::release)); } protected  Resource(MonadDefer<F> monad, Kind<F, Tuple2<T, Consumer1<? super T>>> resource); }
Resource implements ResourceOf<F, T> { public <R> Resource<F, Tuple2<T, R>> combine(Resource<F, ? extends R> other) { return new Resource<>(monad, monad.bracket(resource, t -> monad.bracket(other.resource, r -> monad.pure(Tuple.of(Tuple.of(t.get1(), r.get1()), noop())), Resource::release), 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> Resource<F, Tuple2<T, R>> combine(Resource<F, ? extends R> other) { return new Resource<>(monad, monad.bracket(resource, t -> monad.bracket(other.resource, r -> monad.pure(Tuple.of(Tuple.of(t.get1(), r.get1()), noop())), Resource::release), 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);  }