Ejemplo n.º 1
0
        public static Aff <RT, Arr <B> > TraverseParallel <RT, A, B>(this Arr <Aff <RT, A> > ma, Func <A, B> f, int windowSize)
            where RT : struct, HasCancel <RT> =>
        AffMaybe <RT, Arr <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 <Arr <B> >(fails.Head())
                    : FinSucc <Arr <B> >(toArray(succs)));
        });
Ejemplo n.º 2
0
        public static Aff <Arr <B> > TraverseParallel <A, B>(this Arr <Aff <A> > ma, Func <A, B> f, int windowSize) =>
        AffMaybe <Arr <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 <Arr <B> >(fails1[0])
                    : FinSucc <Arr <B> >(toArray(succs)));
        });