/// <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 override Monad <A> Concatenate(Monad <A> otherMonad) { if (!isNothing) { aValue = otherMonad.Return(); } return(this); }
public override Monad <B> App <B>(Monad <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); }
public static Maybe <T> ToMaybe <T>(this Monad <T> value) { return(value.Return()); }
public static Identity <T> ToIdentity <T>(this Monad <T> value) { return(new Identity <T>(value.Return())); }
public override Monad <A> Concatenate(Monad <A> otherMonad) { this.idValue = otherMonad.Return(); return(this); }
public Monad<A> Set(Monad<A> other) { return Pure(other.Return()); }