public static TryAsync <Seq <B> > TraverseParallel <A, B>(this Seq <TryAsync <A> > ma, int windowSize, Func <A, B> f) { return(ToTry(() => Go(ma, f))); async Task <Result <Seq <B> > > Go(Seq <TryAsync <A> > ma, Func <A, B> f) { var rb = await ma.Map(a => a.Map(f).Try()).WindowMap(windowSize, Prelude.identity).ConfigureAwait(false); return(rb.Exists(d => d.IsFaulted) ? rb.Filter(b => b.IsFaulted).Map(b => new Result <Seq <B> >(b.Exception)).Head() : new Result <Seq <B> >(Seq.FromArray(rb.Map(d => d.Value).ToArray()))); } }
public static EitherAsync <L, Seq <B> > TraverseParallel <L, A, B>(this Seq <EitherAsync <L, A> > ma, int windowSize, Func <A, B> f) { return(new EitherAsync <L, Seq <B> >(Go(ma, f))); async Task <EitherData <L, Seq <B> > > Go(Seq <EitherAsync <L, A> > ma, Func <A, B> f) { var rb = await ma.Map(a => a.Map(f).Data).WindowMap(windowSize, identity).ConfigureAwait(false); return(rb.Exists(d => d.State == EitherStatus.IsLeft) ? rb.Filter(d => d.State == EitherStatus.IsLeft).Map(d => EitherData.Left <L, Seq <B> >(d.Left)).Head() : EitherData.Right <L, Seq <B> >(Seq.FromArray(rb.Map(d => d.Right).ToArray()))); } }
static Seq <Edit <EqA, A> > normalise1(Seq <Edit <EqA, A> .Insert> inserts, Seq <Edit <EqA, A> .Delete> deletes, Seq <Edit <EqA, A> .Replace> replaces) { if (!inserts.IsEmpty && !deletes.IsEmpty) { return(normalise1(inserts.Tail, deletes.Tail, Edit <EqA, A> .Replace.New(deletes.Head.Position, deletes.Head.Element, inserts.Head.Element).Cons(replaces))); } if (deletes.IsEmpty) { return(toSeq(inserts.Map(i => i as Edit <EqA, A>).ConcatFast(replaces.Take(1)).ToArray())); } if (inserts.IsEmpty) { return(Seq1(deletes.Head as Edit <EqA, A>)); } throw new InvalidOperationException(); }
public static Aff <Seq <B> > SequenceSerial <A, B>(this Seq <A> ta, Func <A, Aff <B> > f) => ta.Map(f).SequenceSerial();
public static OptionAsync <Seq <B> > SequenceSerial <A, B>(this Seq <A> ta, Func <A, OptionAsync <B> > f) => ta.Map(f).SequenceSerial();
public static Aff <RT, Seq <B> > SequenceSerial <RT, A, B>(this Seq <A> ta, Func <A, Aff <RT, B> > f) where RT : struct, HasCancel <RT> => ta.Map(f).SequenceSerial();
public static Eff <RT, Seq <B> > Sequence <RT, A, B>(this Seq <A> ta, Func <A, Eff <RT, B> > f) where RT : struct => ta.Map(f).Sequence();
public static HashSet <Seq <B> > Traverse <A, B>(this Seq <HashSet <A> > ma, Func <A, B> f) => toHashSet(CollT.AllCombinationsOf(ma.Map(xs => xs.ToList()).ToArray(), f) .Map(toSeq));
public static Validation <Fail, Seq <B> > Sequence <Fail, A, B>(this Seq <A> ta, Func <A, Validation <Fail, B> > f) => ta.Map(f).Sequence();
public static EitherAsync <L, Seq <B> > SequenceParallel <L, A, B>(this Seq <A> ta, Func <A, EitherAsync <L, B> > f, int windowSize) => ta.Map(f).SequenceParallel(windowSize);
public static TryAsync <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, TryAsync <B> > f, int windowSize) => ta.Map(f).SequenceParallel(windowSize);
public static Aff <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, Aff <B> > f) => ta.Map(f).SequenceParallel();
public static HashSet <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, HashSet <B> > f) => ta.Map(f).Sequence();
public static ValueTask <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, ValueTask <B> > f, int windowSize) => ta.Map(f).SequenceParallel(windowSize);
public static ValueTask <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, ValueTask <B> > f) => ta.Map(f).SequenceParallel();
public static Validation <MonoidFail, Fail, Seq <B> > Sequence <MonoidFail, Fail, A, B>(this Seq <A> ta, Func <A, Validation <MonoidFail, Fail, B> > f) where MonoidFail : struct, Monoid <Fail>, Eq <Fail> => ta.Map(f).Traverse(Prelude.identity);
public static State <S, Seq <B> > Sequence <S, A, B>(this Seq <A> ta, Func <A, State <S, B> > f) => ta.Map(f).Sequence();
public static Aff <RT, Seq <B> > SequenceParallel <RT, A, B>(this Seq <A> ta, Func <A, Aff <RT, B> > f, int windowSize) where RT : struct, HasCancel <RT> => ta.Map(f).SequenceParallel(windowSize);
public static TryAsync <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, TryAsync <B> > f) => ta.Map(f).SequenceParallel();
public static IEnumerable <Seq <B> > Sequence <A, B>(this Seq <A> ma, Func <A, IEnumerable <B> > f) => ma.Map(f).Sequence();
public static EitherAsync <L, Seq <B> > SequenceParallel <L, A, B>(this Seq <A> ta, Func <A, EitherAsync <L, B> > f) => ta.Map(f).SequenceParallel();
public static IEnumerable <Seq <B> > Traverse <A, B>(this Seq <IEnumerable <A> > ma, Func <A, B> f) => CollT.AllCombinationsOf(ma.Map(xs => xs.ToList()).ToArray(), f) .Map(toSeq);
public static Try <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, Try <B> > f) => ta.Map(f).Sequence();
public static EitherUnsafe <L, Seq <B> > Sequence <L, A, B>(this Seq <A> ta, Func <A, EitherUnsafe <L, B> > f) => ta.Map(f).Sequence();
public ISeqInternal <A> Filter(Func <A, bool> f) => new SeqConcat <A>(ms.Map(s => s.Filter(f)));
public static Que <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, Que <B> > f) => ta.Map(f).Traverse(Prelude.identity);
public static Lst <Seq <B> > Traverse <A, B>(this Seq <Lst <A> > ma, Func <A, B> f) => CollT.AllCombinationsOf(ma.Map(xs => xs.ToList()).ToArray(), f) .Map(toSeq) .Freeze();
public static Stck <Seq <B> > Traverse <A, B>(this Seq <Stck <A> > ma, Func <A, B> f) => toStack(CollT.AllCombinationsOf(ma.Map(xs => xs.ToList()).ToArray(), f) .Map(xs => Seq(xs)));
public static Option <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, Option <B> > f) => ta.Map(f).Sequence();
public static Writer <MonoidW, W, Seq <B> > Sequence <MonoidW, W, A, B>(this Seq <A> ta, Func <A, Writer <MonoidW, W, B> > f) where MonoidW : struct, Monoid <W> => ta.Map(f).Sequence();