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