Created
September 12, 2014 13:32
-
-
Save mariogarcia/c41a66d498bc7be5a6cc to your computer and use it in GitHub Desktop.
ListMonad bind draft implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public <B, M extends Monad<B>> M bind(Function<A, M> fn) { | |
List<B> result = new ArrayList<>(); | |
for(A v : this.getTypedRef().getValue()) { | |
ListMonad<B> partialMonad = (ListMonad<B>) fn.apply(v); | |
result.addAll(partialMonad.getTypedRef().getValue()); | |
} | |
return (M) result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment