Created
December 9, 2015 22:34
-
-
Save gszeliga/6a5fcd0849a70f901dc5 to your computer and use it in GitHub Desktop.
This file contains 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
public static class FutureCompositions<V , A extends WannabeApplicative<V>>{ | |
private final Supplier<CompletableFuture<Outcome<A>>> _partial; | |
private FutureCompositions(Supplier<CompletableFuture<Outcome<A>>> state) | |
{ | |
_partial=state; | |
} | |
public FutureCompositions<V, A> binding(Partial<A> stage) | |
{ | |
return new FutureCompositions<>(() -> stage.apply(_partial.get())); | |
} | |
public CompletableFuture<Outcome<V>> perform() | |
{ | |
return _partial.get().thenApply(p -> p.mapR(WannabeApplicative::apply)); | |
} | |
public static <V, A extends WannabeApplicative<V>> FutureCompositions<V, A> begin(A applicative) | |
{ | |
return new FutureCompositions<>(() -> completedFuture(maybe(applicative))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment