public static Aff <RT, Seq <B> > TraverseParallel <RT, A, B>(this Seq <Aff <RT, A> > ma, Func <A, B> f, int windowSize) where RT : struct, HasCancel <RT> => AffMaybe <RT, Seq <B> >(async env => { var rs = await ma.AsEnumerable().Map(m => m.Run(env)).WindowMap(windowSize, fa => fa.Map(f)); var(fails, succs) = rs.Partition(); return(fails.Any() ? FinFail <Seq <B> >(fails.Head()) : FinSucc <Seq <B> >(Seq.FromArray(succs.ToArray()))); });
public static Aff <Seq <B> > TraverseParallel <A, B>(this Seq <Aff <A> > ma, Func <A, B> f, int windowSize) => AffMaybe <Seq <B> >(async() => { var rs = await ma.AsEnumerable().Map(m => m.Run()).WindowMap(windowSize, fa => fa.Map(f)).ConfigureAwait(false); var(fails, succs) = rs.Partition(); var fails1 = fails.Take(1).ToArray(); return(fails1.Length == 1 ? FinFail <Seq <B> >(fails1[0]) : FinSucc <Seq <B> >(Seq.FromArray(succs.ToArray()))); });
public static Seq <A> ConcatFast <A>(this Seq <A> ma, Seq <A> mb) { if (ma == null && mb == null) { return(Empty); } if (ma == null) { return(mb); } if (mb == null) { return(ma); } return(Seq(new ConcatEnum <A>(new[] { ma.AsEnumerable(), mb.AsEnumerable() }, 2))); }
public static Seq <B> rights <CHOICE, CH, A, B>(Seq <CH> ma) where CHOICE : struct, ChoiceUnsafe <CH, A, B> => Seq(rights <CHOICE, CH, A, B>(ma.AsEnumerable()));
public static Seq <F> Fails <F, S>(this Seq <Validation <F, S> > vs) => Seq(Fails(vs.AsEnumerable()));
public static Seq <S> Successes <F, S>(this Seq <Validation <F, S> > vs) => Seq(Successes(vs.AsEnumerable()));
public static Seq <F> Fails <MonoidF, F, S>(this Seq <Validation <MonoidF, F, S> > vs) where MonoidF : struct, Monoid <F>, Eq <F> => Seq(Fails(vs.AsEnumerable()));
public static Seq <S> Successes <MonoidF, F, S>(this Seq <Validation <MonoidF, F, S> > vs) where MonoidF : struct, Monoid <F>, Eq <F> => toSeq(Successes(vs.AsEnumerable()));
public static async Task <Seq <B> > rightsAsync <CHOICE, CH, A, B>(Seq <CH> ma) where CHOICE : struct, ChoiceAsync <CH, A, B> => Seq(await rightsAsync <CHOICE, CH, A, B>(ma.AsEnumerable()));
public static Seq <A> lefts <CHOICE, CH, A, B>(Seq <CH> ma) where CHOICE : struct, ChoiceUnsafe <CH, A, B> => Prelude.toSeq(lefts <CHOICE, CH, A, B>(ma.AsEnumerable()));
public static async Task <Seq <B> > rightsAsync <CHOICE, CH, A, B>(Seq <CH> ma) where CHOICE : struct, ChoiceAsync <CH, A, B> => Prelude.toSeq(await rightsAsync <CHOICE, CH, A, B>(ma.AsEnumerable()).ConfigureAwait(false));
public static async Task <Seq <A> > leftsUnsafeAsync <CHOICE, CH, A, B>(Seq <CH> ma) where CHOICE : struct, ChoiceUnsafeAsync <CH, A, B> => Prelude.toSeq(await leftsUnsafeAsync <CHOICE, CH, A, B>(ma.AsEnumerable()).ConfigureAwait(false));
public static async Task <Seq <A> > leftsUnsafeAsync <CHOICE, CH, A, B>(Seq <CH> ma) where CHOICE : struct, ChoiceUnsafeAsync <CH, A, B> => Seq(await leftsUnsafeAsync <CHOICE, CH, A, B>(ma.AsEnumerable()));