コード例 #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())));
            }
        }
コード例 #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())));
            }
        }
コード例 #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();
 }
コード例 #4
0
ファイル: AffPureT.cs プロジェクト: IDisposable/language-ext
 public static Aff <Seq <B> > SequenceSerial <A, B>(this Seq <A> ta, Func <A, Aff <B> > f) =>
 ta.Map(f).SequenceSerial();
コード例 #5
0
 public static OptionAsync <Seq <B> > SequenceSerial <A, B>(this Seq <A> ta, Func <A, OptionAsync <B> > f) =>
 ta.Map(f).SequenceSerial();
コード例 #6
0
ファイル: AffT.cs プロジェクト: IDisposable/language-ext
 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();
コード例 #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();
コード例 #8
0
ファイル: HashSet.cs プロジェクト: Protiguous/language-ext
 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));
コード例 #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();
コード例 #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);
コード例 #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);
コード例 #12
0
ファイル: AffPureT.cs プロジェクト: IDisposable/language-ext
 public static Aff <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, Aff <B> > f) =>
 ta.Map(f).SequenceParallel();
コード例 #13
0
ファイル: HashSetT.cs プロジェクト: wdolek/language-ext
 public static HashSet <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, HashSet <B> > f) =>
 ta.Map(f).Sequence();
コード例 #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);
コード例 #15
0
 public static ValueTask <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, ValueTask <B> > f) =>
 ta.Map(f).SequenceParallel();
コード例 #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);
コード例 #17
0
ファイル: StateT.cs プロジェクト: IDisposable/language-ext
 public static State <S, Seq <B> > Sequence <S, A, B>(this Seq <A> ta, Func <A, State <S, B> > f) =>
 ta.Map(f).Sequence();
コード例 #18
0
ファイル: AffT.cs プロジェクト: IDisposable/language-ext
 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);
コード例 #19
0
 public static TryAsync <Seq <B> > SequenceParallel <A, B>(this Seq <A> ta, Func <A, TryAsync <B> > f) =>
 ta.Map(f).SequenceParallel();
コード例 #20
0
 public static IEnumerable <Seq <B> > Sequence <A, B>(this Seq <A> ma, Func <A, IEnumerable <B> > f) =>
 ma.Map(f).Sequence();
コード例 #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();
コード例 #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);
コード例 #23
0
ファイル: TryT.cs プロジェクト: wdolek/language-ext
 public static Try <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, Try <B> > f) =>
 ta.Map(f).Sequence();
コード例 #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();
コード例 #25
0
 public ISeqInternal <A> Filter(Func <A, bool> f) =>
 new SeqConcat <A>(ms.Map(s => s.Filter(f)));
コード例 #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);
コード例 #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();
コード例 #28
0
ファイル: StckT.cs プロジェクト: wdolek/language-ext
 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)));
コード例 #29
0
 public static Option <Seq <B> > Sequence <A, B>(this Seq <A> ta, Func <A, Option <B> > f) =>
 ta.Map(f).Sequence();
コード例 #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();