Esempio n. 1
0
 public bool Eq(Either <X, A> t1, Either <X, A> t2)
 {
     return(t1.Cata(
                x1 => t2.Cata(
                    x2 => xeq.Eq(x1, x2),
                    a2 => false),
                a1 => t2.Cata(
                    x2 => false,
                    a2 => aeq.Eq(a1, a2))));
 }
Esempio n. 2
0
 public static bool LeftTest <X, A>(this Either <X, A> either, Func <X, bool> predicate)
 {
     return(either.Cata(predicate, a => false));
 }
Esempio n. 3
0
 public static bool RightTest <X, A>(this Either <X, A> either, Func <A, bool> predicate)
 {
     return(either.Cata(x => false, predicate));
 }
Esempio n. 4
0
 public static IEnumerable <X> LeftEnumerable <X, A>(this Either <X, A> either)
 {
     return(either.Cata(
                x => x.PureEnumerable(),
                a => Enumerable.Empty <X>()));
 }
Esempio n. 5
0
 public static IEnumerable <A> RightEnumerable <X, A>(this Either <X, A> either)
 {
     return(either.Cata(
                x => Enumerable.Empty <A>(),
                a => a.PureEnumerable()));
 }
Esempio n. 6
0
 public static Maybe <X> LeftMaybe <X, A>(this Either <X, A> either)
 {
     return(either.Cata(
                Maybe.Just,
                a => Maybe.Nothing <X>()));
 }
Esempio n. 7
0
 public static Maybe <A> RightMaybe <X, A>(this Either <X, A> either)
 {
     return(either.Cata(
                x => Maybe.Nothing <A>(),
                Maybe.Just));
 }
Esempio n. 8
0
 public static Validation <X, A> Validation <X, A>(this Either <X, A> either)
 {
     return(either.Cata(
                Jib.Validation.Failure <X, A>,
                Jib.Validation.Success <X, A>));
 }
Esempio n. 9
0
File: Bind.cs Progetto: jedahu/Jib
 public static Either <Y, A> BindLeft <X, Y, A>(this Either <X, A> either, Func <X, Either <Y, A> > f)
 {
     return(either.Cata(f, Either.Right <Y, A>));
 }
Esempio n. 10
0
File: Bind.cs Progetto: jedahu/Jib
 public static Either <X, B> Bind <X, A, B>(this Either <X, A> either, Func <A, Either <X, B> > f)
 {
     return(either.Cata(Either.Left <X, B>, f));
 }
Esempio n. 11
0
 public static void CataVoid <X, A>(this Either <X, A> either, Action <X> left, Action <A> right)
 {
     either.Cata(Unit.Func(left), Unit.Func(right));
 }
Esempio n. 12
0
 public Either <X, B> Map <X, A, B>(Either <X, A> either, Func <A, B> f)
 {
     return(either.Cata(Either.Left <X, B>, a => Either.Right <X, B>(f(a))));
 }
Esempio n. 13
0
 public static IEnumerable <Either <X, A> > SequenceEnumerable <X, A>(this Either <X, IEnumerable <A> > either)
 {
     return(either.Cata(
                x => Either.Left <X, A>(x).PureEnumerable(),
                a => a.Select(Either.Right <X, A>)));
 }
Esempio n. 14
0
 public static IEnumerable <Either <X, B> > TraverseEnumerable <A, B, X>(this Either <X, A> either, Func <A, IEnumerable <B> > f)
 {
     return(either.Cata(
                x => Either.Left <X, B>(x).PureEnumerable(),
                a => f(a).Select(Either.Right <X, B>)));
 }