Esempio n. 1
0
 /// <summary>
 /// Represents a successful operation
 /// </summary>
 /// <typeparam name="ERROR">Error type</typeparam>
 /// <typeparam name="A">Value type</typeparam>
 /// <param name="value">Value</param>
 /// <returns>Validation applicative</returns>
 public static Validation <ERROR, A> Success <ERROR, A>(A value) =>
 Validation <ERROR, A> .Success(value);
Esempio n. 2
0
 /// <summary>
 /// Represents a successful operation
 /// </summary>
 /// <typeparam name="MonoidError">Monoid for collecting the errors</typeparam>
 /// <typeparam name="ERROR">Error type</typeparam>
 /// <typeparam name="A">Value type</typeparam>
 /// <param name="value">Value</param>
 /// <returns>Validation applicative</returns>
 public static Validation <MonoidError, ERROR, A> Success <MonoidError, ERROR, A>(A value)
     where MonoidError : struct, Monoid <ERROR>, Eq <ERROR> =>
 Validation <MonoidError, ERROR, A> .Success(value);
Esempio n. 3
0
 public static IEnumerable <Validation <Fail, B> > Sequence <Fail, A, B>(this Validation <Fail, A> ma, Func <A, IEnumerable <B> > f) =>
 ma.Map(f).Sequence();
Esempio n. 4
0
 public static Validation <MonoidFail, Fail, Validation <MonoidFail, Fail, B> > Sequence <MonoidFail, Fail, A, B>(this Validation <MonoidFail, Fail, A> ta, Func <A, Validation <MonoidFail, Fail, B> > f)
     where MonoidFail : struct, Monoid <Fail>, Eq <Fail> =>
 ta.Map(f).Traverse(Prelude.identity);
Esempio n. 5
0
 public static HashSet <Validation <FAIL, B> > Sequence <FAIL, A, B>(this Validation <FAIL, A> ta, Func <A, HashSet <B> > f) =>
 ta.Map(f).Sequence();
Esempio n. 6
0
 public static ValueTask <Validation <FAIL, A> > Sequence <FAIL, A>(this Validation <FAIL, ValueTask <A> > ta) =>
 ta.Traverse(identity);
Esempio n. 7
0
 public static Stck <Validation <FAIL, B> > Sequence <FAIL, A, B>(this Validation <FAIL, A> ta, Func <A, Stck <B> > f) =>
 ta.Map(f).Traverse(Prelude.identity);
Esempio n. 8
0
 public static Validation <MonoidFail, FAIL, R> Apply <MonoidFail, FAIL, A, R>(this ValueTuple <Validation <MonoidFail, FAIL, A> > items, Func <A, R> f)
     where MonoidFail : struct, Monoid <FAIL>, Eq <FAIL> =>
 items.Item1.Match(
     Succ : s => f(s),
     Fail : e => Validation <MonoidFail, FAIL, R> .Fail(e));
Esempio n. 9
0
 public static Aff <RT, Validation <MonoidFail, FAIL, A> > Sequence <RT, MonoidFail, FAIL, A>(this Validation <MonoidFail, FAIL, Aff <RT, A> > mma)
     where MonoidFail : struct, Monoid <FAIL>, Eq <FAIL>
     where RT : struct, HasCancel <RT> =>
 mma.Traverse(identity);
Esempio n. 10
0
 public static Aff <RT, Validation <MonoidFail, FAIL, B> > Sequence <RT, MonoidFail, FAIL, A, B>(this Validation <MonoidFail, FAIL, A> ta, Func <A, Aff <RT, B> > f)
     where MonoidFail : struct, Monoid <FAIL>, Eq <FAIL>
     where RT : struct, HasCancel <RT> =>
 ta.Map(f).Sequence();
Esempio n. 11
0
 public static Aff <RT, Validation <FAIL, B> > Sequence <RT, FAIL, A, B>(this Validation <FAIL, A> ta, Func <A, Aff <RT, B> > f)
     where RT : struct, HasCancel <RT> =>
 ta.Map(f).Sequence();
Esempio n. 12
0
 public static Aff <RT, Validation <FAIL, A> > Sequence <RT, FAIL, A>(this Validation <FAIL, Aff <RT, A> > mma)
     where RT : struct, HasCancel <RT> =>
 mma.Traverse(identity);
Esempio n. 13
0
 public static Eff <RT, Validation <FAIL, B> > Sequence <RT, FAIL, A, B>(this Validation <FAIL, A> ta, Func <A, Eff <RT, B> > f) where RT : struct =>
 ta.Map(f).Sequence();
Esempio n. 14
0
 /// <summary>
 /// Represents a failed operation
 /// </summary>
 /// <typeparam name="ERROR">Error type</typeparam>
 /// <typeparam name="A">Value type</typeparam>
 /// <param name="value">Error value</param>
 /// <returns>Validation applicative</returns>
 public static Validation <ERROR, A> Fail <ERROR, A>(ERROR value) =>
 Validation <ERROR, A> .Fail(Seq1(value));
Esempio n. 15
0
 public Validation <MonoidFail, FAIL, U> Bind <U>(Func <SUCCESS, Validation <MonoidFail, FAIL, U> > f) =>
 IsSuccess
         ? f(success)
         : Validation <MonoidFail, FAIL, U> .Fail(FailValue);
Esempio n. 16
0
 /// <summary>
 /// Represents a failed operation
 /// </summary>
 /// <typeparam name="MonoidError">Monoid for collecting the errors</typeparam>
 /// <typeparam name="ERROR">Error type</typeparam>
 /// <typeparam name="A">Value type</typeparam>
 /// <param name="value">Error value</param>
 /// <returns>Validation applicative</returns>
 public static Validation <MonoidError, ERROR, A> Fail <MonoidError, ERROR, A>(ERROR value)
     where MonoidError : struct, Monoid <ERROR>, Eq <ERROR> =>
 Validation <MonoidError, ERROR, A> .Fail(value);
Esempio n. 17
0
        public static TryAsync <Validation <MonoidFail, Fail, B> > Traverse <MonoidFail, Fail, A, B>(this Validation <MonoidFail, Fail, TryAsync <A> > ma, Func <A, B> f)
            where MonoidFail : struct, Monoid <Fail>, Eq <Fail>
        {
            return(ToTry(() => Go(ma, f)));

            async Task <Result <Validation <MonoidFail, Fail, B> > > Go(Validation <MonoidFail, Fail, TryAsync <A> > ma, Func <A, B> f)
            {
                if (ma.IsFail)
                {
                    return(new Result <Validation <MonoidFail, Fail, B> >(Fail <MonoidFail, Fail, B>(ma.FailValue)));
                }
                var rb = await ma.SuccessValue.Try().ConfigureAwait(false);

                if (rb.IsFaulted)
                {
                    return(new Result <Validation <MonoidFail, Fail, B> >(rb.Exception));
                }
                return(new Result <Validation <MonoidFail, Fail, B> >(f(rb.Value)));
            }
        }
Esempio n. 18
0
 public static EitherAsync <L, Validation <FAIL, A> > Sequence <FAIL, L, A>(this Validation <FAIL, EitherAsync <L, A> > ta) =>
 ta.Traverse(identity);
Esempio n. 19
0
 public static HashSet <Validation <FAIL, A> > Sequence <FAIL, A>(this Validation <FAIL, HashSet <A> > ta) =>
 ta.Traverse(identity);
Esempio n. 20
0
 public static HashSet <Validation <MonoidFail, FAIL, B> > Sequence <MonoidFail, FAIL, A, B>(this Validation <MonoidFail, FAIL, A> ta, Func <A, HashSet <B> > f)
     where MonoidFail : struct, Monoid <FAIL>, Eq <FAIL> =>
 ta.Map(f).Traverse(Prelude.identity);
Esempio n. 21
0
 public static Aff <Validation <FAIL, A> > Sequence <FAIL, A>(this Validation <FAIL, Aff <A> > ta) =>
 ta.Traverse(identity);
Esempio n. 22
0
 public static ValueTask <Validation <MonoidFail, FAIL, A> > Sequence <MonoidFail, FAIL, A>(this Validation <MonoidFail, FAIL, ValueTask <A> > ta)
     where MonoidFail : struct, Monoid <FAIL>, Eq <FAIL> =>
 ta.Traverse(identity);
Esempio n. 23
0
 public static TryOptionAsync <Validation <FAIL, B> > Sequence <FAIL, A, B>(this Validation <FAIL, A> ta, Func <A, TryOptionAsync <B> > f) =>
 ta.Map(f).Sequence();
Esempio n. 24
0
 public static IEnumerable <Validation <MonoidFail, Fail, B> > Sequence <MonoidFail, Fail, A, B>(this Validation <MonoidFail, Fail, A> ma, Func <A, IEnumerable <B> > f)
     where MonoidFail : struct, Monoid <Fail>, Eq <Fail> =>
 ma.Map(f).Traverse(Prelude.identity);
Esempio n. 25
0
 public static Arr <Validation <FAIL, B> > Sequence <FAIL, A, B>(this Validation <FAIL, A> ta, Func <A, Arr <B> > f) =>
 ta.Map(f).Sequence();