/// <summary> /// If this is not nothing, then the result monad is a new Maybe<A> with the value inside the other monad. /// </summary> /// <param name="otherMonad">The other monad.</param> /// <returns>The new monad.</returns> public IMonad <A> Concat(IMonad <A> otherMonad) { Maybe <A> resultMonad = new Nothing <A>(); if (!isNothing) { resultMonad = new Just <A>(otherMonad.Return()); } return(resultMonad); }
public IMonad <B> App <B>(IMonad <Func <A, B> > functionMonad) { Maybe <B> result = new Nothing <B>(); if (this is Just <A> && functionMonad != null) { foreach (var function in functionMonad) { if (function != null) { result = new Just <B>(functionMonad.Return()(aValue)); } } if (result == null) { result = new Nothing <B>(); } } return(result); }