Exemplo n.º 1
0
 public static Either <A, B> Right <A, B>(this B b) => Either <A, B> .Right(b);
Exemplo n.º 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)));
Exemplo n.º 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));
Exemplo n.º 4
0
 public static Either <A, B> Left <A, B>(this A a) => Either <A, B> .Left(a);
Exemplo n.º 5
0
 public static Either <X, A> Flatten <X, A>(this Either <X, Either <X, A> > o) => o.SelectMany(z => z);
Exemplo n.º 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)));
Exemplo n.º 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)));
Exemplo n.º 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);
Exemplo n.º 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)));