Пример #1
0
 private bool Equals(Either <L, R> other)
 {
     return(IsRight == other.IsRight && EqualityComparer <L> .Default.Equals(LeftValue, other.LeftValue) && EqualityComparer <R> .Default.Equals(RightValue, other.RightValue));
 }
Пример #2
0
 public Either <L, TResult> SelectMany <TResult>(Func <R, Either <L, TResult> > f)
 {
     return(IsRight
         ? f(RightValue)
         : Either <L, TResult> .Left(LeftValue));
 }
Пример #3
0
 public Either <L, TResult> SelectMany <TCollection, TResult>(Func <R, Either <L, TCollection> > collectionSelector, Func <R, TCollection, TResult> resultSelector)
 {
     return(!IsRight
         ? Either <L, TResult> .Left(LeftValue)
         : collectionSelector(RightValue).Match(Either <L, TResult> .Left, x => Either <L, TResult> .Right(resultSelector(RightValue, x))));
 }
Пример #4
0
 public Either <L, TResult> Select <TResult>(Func <R, TResult> f)
 {
     return(IsRight
         ? Either <L, TResult> .Right(f(RightValue))
         : Either <L, TResult> .Left(LeftValue));
 }