public static TryOptionAsync <Que <B> > Traverse <A, B>(this Que <TryOptionAsync <A> > ma, Func <A, B> f) { return(ToTry(() => Go(ma, f))); async Task <OptionalResult <Que <B> > > Go(Que <TryOptionAsync <A> > ma, Func <A, B> f) { var rb = await Task.WhenAll(ma.Map(a => a.Map(f).Try())); return(rb.Exists(d => d.IsFaulted) ? rb.Filter(b => b.IsFaulted).Map(b => new OptionalResult <Que <B> >(b.Exception)).Head() : rb.Exists(d => d.IsNone) ? OptionalResult <Que <B> > .None : new OptionalResult <Que <B> >(new Que <B>(rb.Map(d => d.Value.Value)))); } }
public static EitherAsync <L, Que <B> > Traverse <L, A, B>(this Que <EitherAsync <L, A> > ma, Func <A, B> f) { return(new EitherAsync <L, Que <B> >(Go(ma, f))); async Task <EitherData <L, Que <B> > > Go(Que <EitherAsync <L, A> > ma, Func <A, B> f) { var rb = await Task.WhenAll(ma.Map(a => a.Map(f).Data)).ConfigureAwait(false); return(rb.Exists(d => d.State == EitherStatus.IsLeft) ? rb.Filter(d => d.State == EitherStatus.IsLeft).Map(d => EitherData.Left <L, Que <B> >(d.Left)).Head() : EitherData.Right <L, Que <B> >(new Que <B>(rb.Map(d => d.Right)))); } }
public static TryAsync <Que <B> > Traverse <A, B>(this Que <TryAsync <A> > ma, Func <A, B> f) { return(ToTry(() => Go(ma, f))); async Task <Result <Que <B> > > Go(Que <TryAsync <A> > ma, Func <A, B> f) { var rb = await Task.WhenAll(ma.Map(a => a.Map(f).Try())).ConfigureAwait(false); return(rb.Exists(d => d.IsFaulted) ? rb.Filter(b => b.IsFaulted).Map(b => new Result <Que <B> >(b.Exception)).Head() : new Result <Que <B> >(new Que <B>(rb.Map(d => d.Value)))); } }
public static HashSet <Que <B> > Traverse <A, B>(this Que <HashSet <A> > ma, Func <A, B> f) => toHashSet(CollT.AllCombinationsOf(ma.Map(xs => xs.ToList()).ToArray(), f) .Map(toQueue));
public static Aff <Que <B> > SequenceSerial <A, B>(this Que <A> ta, Func <A, Aff <B> > f) => ta.Map(f).SequenceSerial();
public static Aff <Que <B> > SequenceParallel <A, B>(this Que <A> ta, Func <A, Aff <B> > f, int windowSize) => ta.Map(f).SequenceParallel(windowSize);
public static Aff <Que <B> > SequenceParallel <A, B>(this Que <A> ta, Func <A, Aff <B> > f) => ta.Map(f).SequenceParallel();
public static Stck <Que <B> > Traverse <A, B>(this Que <Stck <A> > ma, Func <A, B> f) => toStack(CollT.AllCombinationsOf(ma.Map(xs => xs.ToList()).ToArray(), f) .Map(toQueue));
public static IEnumerable <Que <B> > Traverse <A, B>(this Que <IEnumerable <A> > ma, Func <A, B> f) => CollT.AllCombinationsOf(ma.Map(xs => xs.ToList()).ToArray(), f) .Map(toQueue);
public static Arr <Que <B> > Traverse <A, B>(this Que <Arr <A> > xxs, Func <A, B> f) => CollT.AllCombinationsOf(xxs.Map(xs => xs.ToList()).ToArray(), f) .Map(toQueue) .ToArr();
public static IEnumerable <Que <B> > Sequence <A, B>(this Que <A> ma, Func <A, IEnumerable <B> > f) => ma.Map(f).Traverse(Prelude.identity);
public static async ValueTask <Que <B> > Traverse <A, B>(this Que <ValueTask <A> > ma, Func <A, B> f) { var rb = await Task.WhenAll(ma.Map(async a => f(await a.ConfigureAwait(false)))).ConfigureAwait(false); return(new Que <B>(rb)); }
public static Aff <RT, Que <B> > SequenceParallel <RT, A, B>(this Que <A> ta, Func <A, Aff <RT, B> > f, int windowSize) where RT : struct, HasCancel <RT> => ta.Map(f).SequenceParallel(windowSize);
public static Aff <RT, Que <B> > SequenceSerial <RT, A, B>(this Que <A> ta, Func <A, Aff <RT, B> > f) where RT : struct, HasCancel <RT> => ta.Map(f).SequenceSerial();
public static Lst <Que <B> > Traverse <A, B>(this Que <Lst <A> > ma, Func <A, B> f) => CollT.AllCombinationsOf(ma.Map(xs => xs.ToList()).ToArray(), f) .Map(toQueue) .Freeze();
public static Eff <Que <B> > Sequence <A, B>(this Que <A> ta, Func <A, Eff <B> > f) => ta.Map(f).Sequence();
public static Eff <RT, Que <B> > Sequence <RT, A, B>(this Que <A> ta, Func <A, Eff <RT, B> > f) where RT : struct => ta.Map(f).Sequence();
public static async Task <Que <B> > Traverse <A, B>(this Que <Task <A> > ma, Func <A, B> f) { var rb = await Task.WhenAll(ma.Map(async a => f(await a))); return(new Que <B>(rb)); }