@Test public void zip(){ Try<Tuple2<Future<String>, Future<String>>, Throwable> t = acquireNamed("left") .zip(acquireNamed("right"), Tuple::tuple) .flatMap(f -> acquireNamed(f.toString() + "hello")) .zip(acquireNamed("another"), Tuple::tuple) .run(); System.out.println(t); assertTrue(t.isSuccess()); Try<Tuple2<String, String>, Throwable> r = t.map(t2 -> tuple(t2._1().orElse(""), t2._2().orElse(""))); assertThat(r.orElse(tuple(null,null)),equalTo(tuple("[FUTURE[LEFT],FUTURE[RIGHT]]HELLO","ANOTHER"))); }
public final <T2,R> Managed<R> zip(Managed<T2> b, BiFunction<? super T,? super T2,? extends R> fn){ return flatMap(t1 -> b.map(t2 -> fn.apply(t1, t2))); }
Managed implements Higher<managed,T>,To<Managed<T>>, Publisher<T> { public final <T2,R> Managed<R> zip(Managed<T2> b, BiFunction<? super T,? super T2,? extends R> fn){ return flatMap(t1 -> b.map(t2 -> fn.apply(t1, t2))); } }
Managed implements Higher<managed,T>,To<Managed<T>>, Publisher<T> { public final <T2,R> Managed<R> zip(Managed<T2> b, BiFunction<? super T,? super T2,? extends R> fn){ return flatMap(t1 -> b.map(t2 -> fn.apply(t1, t2))); }  }
Managed implements Higher<managed,T>,To<Managed<T>>, Publisher<T> { public final <T2,R> Managed<R> zip(Managed<T2> b, BiFunction<? super T,? super T2,? extends R> fn){ return flatMap(t1 -> b.map(t2 -> fn.apply(t1, t2))); }  static Managed<T> managed(T acq, Consumer<T> cleanup); static Managed<T> managed(T acq); static Managed<T> of(Publisher<T> acq, Consumer<T> cleanup); static Managed<T> of(Supplier<? extends T> acq, Consumer<T> cleanup); static Managed<T> of(Supplier<? extends T> acq); static Managed<T> checked(CheckedSupplier<? extends T> acq); static Managed<T> of(Publisher<T> acq); static Managed<T> of(IO<T> acquire, Consumer<T> cleanup); static Managed<T> of(IO<T> acquire); static Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all); Tupled<T,R2> with(Function<? super T, ? extends R2> fn); static Managed<Seq<R>> traverse(Iterable<T> stream,Function<? super T,Managed<? extends R>> fn); static Managed<Seq<R>> traverse(Function<? super T,? extends R> fn, Iterable<Managed<T>> stream); static Managed<T> narrow(Managed<? extends T> broad); final Managed<R> zip(Managed<T2> b, BiFunction<? super T,? super T2,? extends R> fn); abstract IO<R> apply(Function<? super T,? extends IO<R>> fn); final void forEach(Consumer<? super T> onNext,Consumer<Throwable> errorHandler); final Try<T,Throwable> run(); final T runAndThrowUnexpected(); final R foldRun(Function<? super Try<T,Throwable>,? extends R> transform); final Future<T> future(); final Try<T,Throwable> runAsync(Executor ex); ReactiveSeq<T> stream(); Managed<R> checkedMap(CheckedFunction<? super T, ? extends R> mapper); Managed<R> map(Function<? super T, ? extends R> mapper); Managed<R> checkedFlatMap(CheckedFunction<? super T, Managed<R>> f); Managed<R> flatMap(Function<? super T, Managed<R>> f); static Semigroup<Managed<T>> semigroup(Semigroup<T> s); static Monoid<Managed<T>> monoid(Monoid<T> s); @Override void subscribe(Subscriber<? super T> s); IO<T> io(); }
Managed implements Higher<managed,T>,To<Managed<T>>, Publisher<T> { public final <T2,R> Managed<R> zip(Managed<T2> b, BiFunction<? super T,? super T2,? extends R> fn){ return flatMap(t1 -> b.map(t2 -> fn.apply(t1, t2))); }  static Managed<T> managed(T acq, Consumer<T> cleanup); static Managed<T> managed(T acq); static Managed<T> of(Publisher<T> acq, Consumer<T> cleanup); static Managed<T> of(Supplier<? extends T> acq, Consumer<T> cleanup); static Managed<T> of(Supplier<? extends T> acq); static Managed<T> checked(CheckedSupplier<? extends T> acq); static Managed<T> of(Publisher<T> acq); static Managed<T> of(IO<T> acquire, Consumer<T> cleanup); static Managed<T> of(IO<T> acquire); static Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all); Tupled<T,R2> with(Function<? super T, ? extends R2> fn); static Managed<Seq<R>> traverse(Iterable<T> stream,Function<? super T,Managed<? extends R>> fn); static Managed<Seq<R>> traverse(Function<? super T,? extends R> fn, Iterable<Managed<T>> stream); static Managed<T> narrow(Managed<? extends T> broad); final Managed<R> zip(Managed<T2> b, BiFunction<? super T,? super T2,? extends R> fn); abstract IO<R> apply(Function<? super T,? extends IO<R>> fn); final void forEach(Consumer<? super T> onNext,Consumer<Throwable> errorHandler); final Try<T,Throwable> run(); final T runAndThrowUnexpected(); final R foldRun(Function<? super Try<T,Throwable>,? extends R> transform); final Future<T> future(); final Try<T,Throwable> runAsync(Executor ex); ReactiveSeq<T> stream(); Managed<R> checkedMap(CheckedFunction<? super T, ? extends R> mapper); Managed<R> map(Function<? super T, ? extends R> mapper); Managed<R> checkedFlatMap(CheckedFunction<? super T, Managed<R>> f); Managed<R> flatMap(Function<? super T, Managed<R>> f); static Semigroup<Managed<T>> semigroup(Semigroup<T> s); static Monoid<Managed<T>> monoid(Monoid<T> s); @Override void subscribe(Subscriber<? super T> s); IO<T> io();  }