Exemplo n.º 1
0
        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())));
            }
        }
Exemplo n.º 2
0
        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())));
            }
        }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
 public static Aff <Seq <B> > SequenceSerial <A, B>(this Seq <A> ta, Func <A, Aff <B> > f) =>
 ta.Map(f).SequenceSerial();
Exemplo n.º 5
0
 public static OptionAsync <Seq <B> > SequenceSerial <A, B>(this Seq <A> ta, Func <A, OptionAsync <B> > f) =>
 ta.Map(f).SequenceSerial();
Exemplo n.º 6
0
 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();
Exemplo n.º 7
0
 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();
Exemplo n.º 8
0
 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));
Exemplo n.º 9
0
 public static Validation <Fail, Seq <B> > Sequence <Fail, A, B>(this Seq <A> ta, Func <A, Validation <Fail, B> > f) =>
 ta.Map(f).Sequence();
Exemplo n.º 10
0
 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);
Exemplo n.º 11
0
 public static TryAsync <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, TryAsync <B> > f, int windowSize) =>
 ta.Map(f).SequenceParallel(windowSize);
Exemplo n.º 12
0
 public static Aff <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, Aff <B> > f) =>
 ta.Map(f).SequenceParallel();
Exemplo n.º 13
0
 public static HashSet <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, HashSet <B> > f) =>
 ta.Map(f).Sequence();
Exemplo n.º 14
0
 public static ValueTask <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, ValueTask <B> > f, int windowSize) =>
 ta.Map(f).SequenceParallel(windowSize);
Exemplo n.º 15
0
 public static ValueTask <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, ValueTask <B> > f) =>
 ta.Map(f).SequenceParallel();
Exemplo n.º 16
0
 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);
Exemplo n.º 17
0
 public static State <S, Seq <B> > Sequence <S, A, B>(this Seq <A> ta, Func <A, State <S, B> > f) =>
 ta.Map(f).Sequence();
Exemplo n.º 18
0
 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);
Exemplo n.º 19
0
 public static TryAsync <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, TryAsync <B> > f) =>
 ta.Map(f).SequenceParallel();
Exemplo n.º 20
0
 public static IEnumerable <Seq <B> > Sequence <A, B>(this Seq <A> ma, Func <A, IEnumerable <B> > f) =>
 ma.Map(f).Sequence();
Exemplo n.º 21
0
 public static EitherAsync <L, Seq <B> > SequenceParallel <L, A, B>(this Seq <A> ta, Func <A, EitherAsync <L, B> > f) =>
 ta.Map(f).SequenceParallel();
Exemplo n.º 22
0
 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);
Exemplo n.º 23
0
 public static Try <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, Try <B> > f) =>
 ta.Map(f).Sequence();
Exemplo n.º 24
0
 public static EitherUnsafe <L, Seq <B> > Sequence <L, A, B>(this Seq <A> ta, Func <A, EitherUnsafe <L, B> > f) =>
 ta.Map(f).Sequence();
Exemplo n.º 25
0
 public ISeqInternal <A> Filter(Func <A, bool> f) =>
 new SeqConcat <A>(ms.Map(s => s.Filter(f)));
Exemplo n.º 26
0
 public static Que <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, Que <B> > f) =>
 ta.Map(f).Traverse(Prelude.identity);
Exemplo n.º 27
0
 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();
Exemplo n.º 28
0
 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)));
Exemplo n.º 29
0
 public static Option <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, Option <B> > f) =>
 ta.Map(f).Sequence();
Exemplo n.º 30
0
 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();