public class AnyMonads extends java.lang.Object implements AnyMFunctions
| Constructor and Description |
|---|
AnyMonads() |
| Modifier and Type | Method and Description |
|---|---|
<T1> AnyM<java.util.stream.Stream<T1>> |
sequence(java.util.Collection<AnyM<T1>> seq)
Convert a Collection of Monads to a Monad with a List
|
<T1> AnyM<java.util.stream.Stream<T1>> |
sequence(java.util.stream.Stream<AnyM<T1>> seq)
Convert a Stream of Monads to a Monad with a List
|
<T,R> AnyM<java.util.List<R>> |
traverse(java.util.Collection<AnyM<T>> seq,
java.util.function.Function<T,R> fn)
Convert a Collection of Monads to a Monad with a List applying the supplied function in the process
|
<T,R> AnyM<java.util.List<R>> |
traverse(java.util.stream.Stream<AnyM<T>> seq,
java.util.function.Function<T,R> fn)
Convert a Stream of Monads to a Monad with a List applying the supplied function in the process
|
public <T,R> AnyM<java.util.List<R>> traverse(java.util.Collection<AnyM<T>> seq, java.util.function.Function<T,R> fn)
List<CompletableFuture<Integer>> futures = createFutures();
AnyM<List<String>> futureList = AnyMonads.traverse(AsAnyMList.anyMList(futures), (Integer i) -> "hello" +i);
traverse in interface AnyMFunctionsseq - Collection of Monadsfn - Function to applypublic <T,R> AnyM<java.util.List<R>> traverse(java.util.stream.Stream<AnyM<T>> seq, java.util.function.Function<T,R> fn)
Stream<CompletableFuture<Integer>> futures = createFutures();
AnyM<List<String>> futureList = AnyMonads.traverse(AsAnyMList.anyMList(futures), (Integer i) -> "hello" +i);
traverse in interface AnyMFunctionsseq - Stream of Monadsfn - Function to applypublic <T1> AnyM<java.util.stream.Stream<T1>> sequence(java.util.Collection<AnyM<T1>> seq)
List<CompletableFuture<Integer>> futures = createFutures();
AnyM<List<Integer>> futureList = AnyMonads.sequence(AsAnyMList.anyMList(futures));
//where AnyM wraps CompletableFuture<List<Integer>>
sequence in interface AnyMFunctionsseq - Collection of monads to convertfor helper methods to convert a List of Monads / Collections to List of AnyMpublic <T1> AnyM<java.util.stream.Stream<T1>> sequence(java.util.stream.Stream<AnyM<T1>> seq)
Stream<CompletableFuture<Integer>> futures = createFutures();
AnyM<List<Integer>> futureList = AnyMonads.sequence(AsAnyMList.anyMList(futures));
//where AnyM wraps CompletableFuture<List<Integer>>
sequence in interface AnyMFunctionsseq - Stream of monads to convertfor helper methods to convert a List of Monads / Collections to List of AnyM