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)); }
public Either <L, TResult> SelectMany <TResult>(Func <R, Either <L, TResult> > f) { return(IsRight ? f(RightValue) : Either <L, TResult> .Left(LeftValue)); }
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)))); }
public Either <L, TResult> Select <TResult>(Func <R, TResult> f) { return(IsRight ? Either <L, TResult> .Right(f(RightValue)) : Either <L, TResult> .Left(LeftValue)); }