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