@Test public void sequence(){ assertThat(Managed.Comprehensions.forEach(resource(1),t->resource(t.getOrElse(0)+1)).run().map(f->f.orElse(-1)).orElse(-1),equalTo(2)); }
public static <T> Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all) { Managed<Seq<T>> acc =null; for(Managed<T> n : all){ if(acc==null) acc=n.map(Seq::of); else acc = acc.zip(n,(a,b)->a.append(b)); } return acc; }
FluxManaged extends Managed<T> { public static <T> Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all) { Managed<Seq<T>> acc =null; for(Managed<T> n : all){ if(acc==null) acc=n.map(Seq::of); else acc = acc.zip(n,(a,b)->a.append(b)); } return acc; } }
FluxManaged extends Managed<T> { public static <T> Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all) { Managed<Seq<T>> acc =null; for(Managed<T> n : all){ if(acc==null) acc=n.map(Seq::of); else acc = acc.zip(n,(a,b)->a.append(b)); } return acc; }  }
FluxManaged extends Managed<T> { public static <T> Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all) { Managed<Seq<T>> acc =null; for(Managed<T> n : all){ if(acc==null) acc=n.map(Seq::of); else acc = acc.zip(n,(a,b)->a.append(b)); } return acc; }  static Managed<T> managed(T just,Consumer<T> cleanup); static Managed<T> of(Supplier<? extends T> s, Consumer<T> cleanup); static Managed<T> managed(T just); static Managed<T> of(Supplier<? extends T> s); static Managed<T> of(Publisher<T> acq); final static Semigroup<Managed<T>> semigroup(Semigroup<T> s); final static Monoid<Managed<T>> monoid(Monoid<T> s); 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); Managed<R> map(Function<? super T, ? extends R> mapper); Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f); }
FluxManaged extends Managed<T> { public static <T> Managed<Seq<T>> sequence(Iterable<? extends Managed<T>> all) { Managed<Seq<T>> acc =null; for(Managed<T> n : all){ if(acc==null) acc=n.map(Seq::of); else acc = acc.zip(n,(a,b)->a.append(b)); } return acc; }  static Managed<T> managed(T just,Consumer<T> cleanup); static Managed<T> of(Supplier<? extends T> s, Consumer<T> cleanup); static Managed<T> managed(T just); static Managed<T> of(Supplier<? extends T> s); static Managed<T> of(Publisher<T> acq); final static Semigroup<Managed<T>> semigroup(Semigroup<T> s); final static Monoid<Managed<T>> monoid(Monoid<T> s); 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); Managed<R> map(Function<? super T, ? extends R> mapper); Managed<R> flatMap(Function<? super T, cyclops.reactive.Managed<R>> f);  }