public static EitherAsync <L, HashSet <B> > Traverse <L, A, B>(this HashSet <EitherAsync <L, A> > ma, Func <A, B> f)
        {
            return(new EitherAsync <L, HashSet <B> >(Go(ma, f)));

            async Task <EitherData <L, HashSet <B> > > Go(HashSet <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, HashSet <B> >(d.Left)).Head()
                    : EitherData.Right <L, HashSet <B> >(new HashSet <B>(rb.Map(d => d.Right))));
            }
        }
Beispiel #2
0
        public static TryAsync <HashSet <B> > Traverse <A, B>(this HashSet <TryAsync <A> > ma, Func <A, B> f)
        {
            return(ToTry(() => Go(ma, f)));

            async Task <Result <HashSet <B> > > Go(HashSet <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 <HashSet <B> >(b.Exception)).Head()
                    : new Result <HashSet <B> >(new HashSet <B>(rb.Map(d => d.Value))));
            }
        }
Beispiel #3
0
 public static Eff <HashSet <B> > Sequence <A, B>(this HashSet <A> ta, Func <A, Eff <B> > f) =>
 ta.Map(f).Sequence();
Beispiel #4
0
 public static HashSet <R> map <T, R>(HashSet <T> set, Func <T, R> mapper) =>
 set.Map(mapper);
 public static IEnumerable <HashSet <B> > Sequence <A, B>(this HashSet <A> ma, Func <A, IEnumerable <B> > f) =>
 ma.Map(f).Sequence();
Beispiel #6
0
 public static Reader <Env, HashSet <B> > Sequence <Env, A, B>(this HashSet <A> ta, Func <A, Reader <Env, B> > f) =>
 ta.Map(f).Sequence();
Beispiel #7
0
 public static Eff <RT, HashSet <B> > Sequence <RT, A, B>(this HashSet <A> ta, Func <A, Eff <RT, B> > f) where RT : struct =>
 ta.Map(f).Sequence();
 public static EitherAsync <L, HashSet <B> > Sequence <L, A, B>(this HashSet <A> ta, Func <A, EitherAsync <L, B> > f) =>
 ta.Map(f).Traverse(Prelude.identity);
Beispiel #9
0
 public static Aff <HashSet <B> > SequenceParallel <A, B>(this HashSet <A> ta, Func <A, Aff <B> > f, int windowSize) =>
 ta.Map(f).SequenceParallel(windowSize);
Beispiel #10
0
 public static State <S, HashSet <B> > Sequence <S, A, B>(this HashSet <A> ta, Func <A, State <S, B> > f) =>
 ta.Map(f).Sequence();
Beispiel #11
0
        public static async ValueTask <HashSet <B> > Traverse <A, B>(this HashSet <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 HashSet <B>(rb));
        }
Beispiel #12
0
 public static Aff <RT, HashSet <B> > SequenceParallel <RT, A, B>(this HashSet <A> ta, Func <A, Aff <RT, B> > f, int windowSize)
     where RT : struct, HasCancel <RT> =>
 ta.Map(f).SequenceParallel(windowSize);
Beispiel #13
0
 public static Aff <RT, HashSet <B> > SequenceSerial <RT, A, B>(this HashSet <A> ta, Func <A, Aff <RT, B> > f)
     where RT : struct, HasCancel <RT> =>
 ta.Map(f).SequenceSerial();
Beispiel #14
0
 public static Writer <MonoidW, W, HashSet <B> > Sequence <MonoidW, W, A, B>(this HashSet <A> ta, Func <A, Writer <MonoidW, W, B> > f)
     where MonoidW : struct, Monoid <W> =>
 ta.Map(f).Sequence();
Beispiel #15
0
 public static RWS <MonoidW, Env, W, S, HashSet <B> > Sequence <MonoidW, Env, W, S, A, B>(this HashSet <A> ta, Func <A, RWS <MonoidW, Env, W, S, B> > f)
     where MonoidW : struct, Monoid <W> =>
 ta.Map(f).Sequence();
Beispiel #16
0
 public static Aff <HashSet <B> > SequenceParallel <A, B>(this HashSet <A> ta, Func <A, Aff <B> > f) =>
 ta.Map(f).SequenceParallel();
 public static HashSet <EqR, R> map <EqT, EqR, T, R>(HashSet <EqT, T> set, Func <T, R> mapper)
     where EqT : struct, Eq <T>
     where EqR : struct, Eq <R> =>
 set.Map <EqR, R>(mapper);
Beispiel #18
0
 public static TryAsync <HashSet <B> > Sequence <A, B>(this HashSet <A> ta, Func <A, TryAsync <B> > f) =>
 ta.Map(f).Traverse(Prelude.identity);
 public static HashSet <EqT, T> map <EqT, T>(HashSet <EqT, T> set, Func <T, T> mapper) where EqT : struct, Eq <T> =>
 set.Map(mapper);
Beispiel #20
0
 public static Validation <Fail, HashSet <B> > Sequence <Fail, A, B>(this HashSet <A> ta, Func <A, Validation <Fail, B> > f) =>
 ta.Map(f).Traverse(Prelude.identity);
Beispiel #21
0
 public static Validation <MonoidFail, Fail, HashSet <B> > Sequence <MonoidFail, Fail, A, B>(this HashSet <A> ta, Func <A, Validation <MonoidFail, Fail, B> > f)
     where MonoidFail : struct, Monoid <Fail>, Eq <Fail> =>
 ta.Map(f).Traverse(Prelude.identity);
Beispiel #22
0
 public static Option <HashSet <B> > Sequence <A, B>(this HashSet <A> ta, Func <A, Option <B> > f) =>
 ta.Map(f).Traverse(Prelude.identity);
Beispiel #23
0
        public static async Task <HashSet <B> > Traverse <A, B>(this HashSet <Task <A> > ma, Func <A, B> f)
        {
            var rb = await Task.WhenAll(ma.Map(async a => f(await a)));

            return(new HashSet <B>(rb));
        }