Skip to content

Instantly share code, notes, and snippets.

@mariogarcia
Created September 12, 2014 13:32
Show Gist options
  • Save mariogarcia/c41a66d498bc7be5a6cc to your computer and use it in GitHub Desktop.
Save mariogarcia/c41a66d498bc7be5a6cc to your computer and use it in GitHub Desktop.
ListMonad bind draft implementation
@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