// SelectMany implementation to allow EitherMonad<R> to be used with Linq query compositions public static EitherMonad <C> SelectMany <A, B, C>(this EitherMonad <A> a, Func <A, EitherMonad <B> > func, Func <A, B, C> select) { var b = a.Bind(func); if (b.IsLeft) { return(EitherMonad <C> .Left(b.LeftValue)); } return(EitherMonad <C> .Return(select(a.RightValue, b.RightValue))); }
public EitherMonad <R2> Bind <R2>(Func <R, EitherMonad <R2> > func) { return(EitherMonad <R2> .Bind(this, func)); }