예제 #1
0
 public static Either <A, B> Right <A, B>(this B b) => Either <A, B> .Right(b);
예제 #2
0
 public Either <A, D> ZipWith <C, D>(Either <A, C> o, Func <B, Func <C, D> > f) =>
 this.SelectMany(a => o.Select(b => f(a)(b)));
예제 #3
0
 public static Pair <Either <X, A>, Either <X, B> > Unzip <X, A, B>(this Either <X, Pair <A, B> > p) => p.Select(q => q._1.Get).And(p.Select(q => q._2.Get));
예제 #4
0
 public static Either <A, B> Left <A, B>(this A a) => Either <A, B> .Left(a);
예제 #5
0
 public static Either <X, A> Flatten <X, A>(this Either <X, Either <X, A> > o) => o.SelectMany(z => z);
예제 #6
0
 public static Either <X, B> Apply <X, A, B>(this Either <X, Func <A, B> > f, Either <X, A> o) =>
 f.SelectMany(g => o.Select(p => g(p)));
예제 #7
0
 public static Either <X, C> SelectMany <X, A, B, C>(this Either <X, A> k, Func <A, Either <X, B> > p, Func <A, B, C> f) =>
 SelectMany(k, a => Select(p(a), b => f(a, b)));
예제 #8
0
 public static Either <X, B> SelectMany <X, A, B>(this Either <X, A> k, Func <A, Either <X, B> > f) =>
 k.Fold(x => Either <X, B> .Left(x), f);
예제 #9
0
 public static Either <X, B> Select <X, A, B>(this Either <X, A> k, Func <A, B> f) =>
 k.Fold(x => Either <X, B> .Left(x), a => Either <X, B> .Right(f(a)));