T - Data types of elements managed by wrapped scalar Monad.public interface AnyMValue<W extends WitnessType<W>,T> extends AnyM<W,T>, Value<T>, Filters<T>, MonadicValue<T>
AnyM.AnyMFactoryValue.ValueImpl<T>Convertable.SupplierToConvertable<T>Fn0.FunctionalOperations<R>, Fn0.Instances, Fn0.SupplierKind<R>| Modifier and Type | Method and Description |
|---|---|
default AnyMValue<W,java.util.List<T>> |
aggregate(AnyM<W,T> next)
Aggregate the contents of this Monad and the supplied Monad
|
default int |
arity() |
default <U> AnyMValue<W,U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a reactiveStream to a given type, possibly throwing a
ClassCastException. |
default <R> AnyMValue<W,R> |
coflatMap(java.util.function.Function<? super MonadicValue<T>,R> mapper)
Perform a coflatMap operation.
|
default <R,A> R |
collect(java.util.stream.Collector<? super T,A,R> collector)
Collect the contents of the monad wrapped by this AnyM into supplied collector
A mutable reduction operation equivalent to Stream#collect
|
default <T2,R> AnyMValue<W,R> |
combine(Value<? extends T2> app,
java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Lazily combine this ApplicativeFunctor with the supplied value via the supplied BiFunction
Example
|
default AnyMValue<W,T> |
combineEager(Monoid<T> monoid,
AnyMValue<W,? extends T> v2) |
default AnyMValue<W,T> |
combineEager(Monoid<T> monoid,
MonadicValue<? extends T> v2)
Eagerly combine two MonadicValues using the supplied monoid (@see ApplicativeFunctor for type appropraite i.e.
|
default <T> AnyMValue<W,T> |
empty()
Construct an AnyM wrapping a new zero instance of the wrapped type
e.g.
|
default <T> AnyMValue<W,T> |
emptyUnit() |
default boolean |
eqv(AnyMValue<?,T> t)
Equivalence test, returns true if this Monad is equivalent to the supplied monad
e.g.
|
default AnyMValue<W,T> |
filter(java.util.function.Predicate<? super T> p)
Perform a filter operation on the wrapped monad instance e.g.
|
default AnyMValue<W,T> |
filterNot(java.util.function.Predicate<? super T> fn)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
default <R> AnyMValue<W,R> |
flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> fn)
A flattening transformation operation (@see
Optional.flatMap(Function) |
default <R> AnyMValue<W,R> |
flatMapA(java.util.function.Function<? super T,? extends AnyM<W,? extends R>> fn) |
default <R> AnyMValue<W,R> |
flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
A flattening transformation operation that takes the first value from the returned Iterable.
|
default <R> AnyMValue<W,R> |
flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn)
A flattening transformation operation that takes the first value from the returned Publisher.
|
default <R> AnyMValue<W,R> |
flatMapS(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> fn) |
default <R1,R> AnyMValue<W,R> |
forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
Perform a two level nested internal iteration over this MonadicValue and the
supplied MonadicValue
|
default <R1,R> AnyMValue<W,R> |
forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
Perform a two level nested internal iteration over this MonadicValue and the
supplied reactiveStream
|
default <T2,R1,R2,R> |
forEach3(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
Perform a three level nested internal iteration over this MonadicValue and the
supplied MonadicValues
|
default <T2,R1,R2,R> |
forEach3(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction,
Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
Perform a three level nested internal iteration over this MonadicValue and the
supplied MonadicValues
|
default <T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends MonadicValue<R3>> value3,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
Perform a four level nested internal iteration over this MonadicValue and the
supplied MonadicValues
|
default <T2,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1,
java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2,
Fn3<? super T,? super R1,? super R2,? extends MonadicValue<R3>> value3,
Fn4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction,
Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
Perform a four level nested internal iteration over this MonadicValue and the
supplied MonadicValues
Maybe.of(3)
.forEach4(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->Maybe.none(),
(a,b,c,d)->a+b+c<100,
(a,b,c,d)->a+b+c+d);
//Maybe.none
|
default T |
get() |
default boolean |
isPresent() |
default java.util.Iterator<T> |
iterator() |
default <R> AnyMValue<W,R> |
map(java.util.function.Function<? super T,? extends R> fn)
Transform this functor using the supplied transformation function
|
default Xor<AnyMValue<W,T>,AnyMSeq<W,T>> |
matchable()
Allows structural matching on the value / seq nature of this AnyM.
|
default java.lang.String |
mkString()
Returns the class name and the name of the subclass, if there is any value, the value is showed between square brackets.
|
default AnyMValue<W,MonadicValue<T>> |
nest()
cojoin pattern.
|
default AnyMValue<W,T> |
notNull()
Filter elements retaining only values which are not null
|
default <U> AnyMValue<W,U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a reactiveStream that are of a given type.
|
default AnyMValue<W,T> |
peek(java.util.function.Consumer<? super T> c)
Perform a peek operation on the wrapped monad e.g.
|
default <R> AnyMValue<W,R> |
retry(java.util.function.Function<? super T,? extends R> fn)
Retry a transformation if it fails.
|
default <R> AnyMValue<W,R> |
retry(java.util.function.Function<? super T,? extends R> fn,
int retries,
long delay,
java.util.concurrent.TimeUnit timeUnit)
Retry a transformation if it fails.
|
default ReactiveSeq<T> |
stream() |
default <R> AnyMValue<W,R> |
trampoline(java.util.function.Function<? super T,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
default <T> AnyMValue<W,T> |
unit(T value)
Construct a new instanceof AnyM using the type of the underlying wrapped monad
|
default AnyMValue<W,T> |
zip(java.util.function.BinaryOperator<Zippable<T>> combiner,
Zippable<T> app)
Combine two applicatives together using the provided BinaryOperator (Semigroup, Monoid and Reducer all
extend BinaryOperator - checkout SemigroupK and Monoids for a large number of canned combinations).
|
default <T2,R> AnyMValue<W,R> |
zip(java.lang.Iterable<? extends T2> app,
java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zip (combine) this Zippable with the supplied Iterable using the supplied combining function
|
default <S,U> AnyMValue<W,org.jooq.lambda.tuple.Tuple3<T,S,U>> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third)
zip 3 Streams into one
|
default <S,U,R> AnyMValue<W,R> |
zip3(java.lang.Iterable<? extends S> second,
java.lang.Iterable<? extends U> third,
Fn3<? super T,? super S,? super U,? extends R> fn3) |
default <T2,T3,T4> AnyMValue<W,org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth)
zip 4 Streams into 1
|
default <T2,T3,T4,R> |
zip4(java.lang.Iterable<? extends T2> second,
java.lang.Iterable<? extends T3> third,
java.lang.Iterable<? extends T4> fourth,
Fn4<? super T,? super T2,? super T3,? super T4,? extends R> fn) |
default <T2,R> AnyMValue<W,R> |
zipP(org.reactivestreams.Publisher<? extends T2> app,
java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zip (combine) this Zippable with the supplied Publisher, using the supplied combining function
|
default <U> AnyMValue<W,org.jooq.lambda.tuple.Tuple2<T,U>> |
zipP(org.reactivestreams.Publisher<? extends U> other) |
default <R> AnyMValue<W,R> |
zipWith(java.lang.Iterable<java.util.function.Function<? super T,? extends R>> fn) |
default <R> AnyMValue<W,R> |
zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super T,? extends R>> fn) |
default <R> AnyMValue<W,R> |
zipWithS(java.util.stream.Stream<java.util.function.Function<? super T,? extends R>> fn) |
adapter, always, always, ap, ap2, coflatMapA, completableFutureOf, eqv, failure, flatten, flattenI, fromArray, fromBagX, fromCollectionX, fromCompletableFuture, fromDeque, fromDoubleStream, fromEither, fromEither3, fromEither4, fromEither5, fromEval, fromFuture, fromFutureStream, fromIdentity, fromIntStream, fromIor, fromIterable, fromLinkedListX, fromList, fromLongStream, fromMaybe, fromMonadicValue, fromOptional, fromOptionalDouble, fromOptionalInt, fromOptionalLong, fromOrderedSetX, fromPersistentQueueX, fromPersistentSetX, fromPublisher, fromQueue, fromSet, fromSortedSet, fromStream, fromStream, fromStream, fromStreamable, fromTry, fromVectorX, fromXor, futureOf, generate, identity, just, later, left, liftF, liftF2, liftF2, liftF3, liftF3, liftF4, liftF4, liftF5, liftF5, liftMFuture, liftMFuture, liftMList, liftMListX, listFromCompletableFuture, listFromEither, listFromEither3, listFromEither4, listFromEither5, listFromEval, listFromFuture, listFromIor, listFromMaybe, listFromOptional, listFromStream, listFromStreamable, listFromXor, listOf, maybeNullable, narrow, nestA, none, ofNullable, ofSeq, ofValue, ofValue, ofValue2, ofValue2, primary, rangeLongOf, rangeOf, reactiveSeq, right, secondary, sequence, sequence, streamOf, success, success, toString, traverse, traverse, unitIterator, zip, zipS, zipSunwrap, unwrapIfInstance, unwrapNestedfutureStream, getStreamable, isEmpty, jdkStream, reveresedJDKStream, reveresedStreamapply, generate, iterate, newSubscriber, of, subscribe, test, toEither, toEval, toEvalAlways, toEvalLater, toEvalNow, toIor, toLeft, toMaybe, toMaybeEager, toRight, toTry, toTry, toTry, toXor, toXorendsWith, endsWithIterable, findAny, findFirst, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleUnsafe, startsWith, startsWithIterable, takeOne, xMatchfromSupplier, orElse, orElseGet, orElseThrow, toCompletableFuture, toCompletableFutureAsync, toFuture, toFutureAsync, toOptional, toStream, visitdefault <R,A> R collect(java.util.stream.Collector<? super T,A,R> collector)
AnyM
AnyM<Integer> monad1 = AnyM.fromStream(Stream.of(1,2,3));
AnyM<Integer> monad2 = AnyM.fromOptional(Optional.of(1));
List<Integer> list1 = monad1.collect(CyclopsCollectors.toList());
List<Integer> list2 = monad2.collect(CyclopsCollectors.toList());
collect in interface AnyM<W extends WitnessType<W>,T>collect in interface Convertable<T>collector - JDK collector to perform mutable reductiondefault boolean eqv(AnyMValue<?,T> t)
{code
Optional.of(1) and CompletableFuture.completedFuture(1) are equivalent
}
t - Monad to compare todefault AnyMValue<W,T> zip(java.util.function.BinaryOperator<Zippable<T>> combiner, Zippable<T> app)
Zippablezip in interface AnyM<W extends WitnessType<W>,T>zip in interface Zippable<T>Semigroup,
Semigroups,
Monoid,
To lift any Semigroup (or monoid) up to handling Applicatives use the combineApplicatives operator in SemigroupK
{@see com.aol.cyclops2.SemigroupK#combineApplicatives(BiFunction) } or Monoids
{ {@see com.aol.cyclops2.Monoids#combineApplicatives(java.util.function.Function, com.aol.cyclops2.function.Monoid)
}
{@code
BinaryOperator> sumMaybes = SemigroupK.combineScalarFunctors(SemigroupK.intSum);
Maybe.just(1).zip(sumMaybes, Maybe.just(5))
//Maybe.just(6));
}
default int arity()
arity in interface MonadicValue<T>default <R> AnyMValue<W,R> coflatMap(java.util.function.Function<? super MonadicValue<T>,R> mapper)
MonadicValue
Maybe.none().coflatMap(m -> m.isPresent() ? m.get() : 10);
//Maybe[10]
coflatMap in interface MonadicValue<T>mapper - Mapping / transformation functiondefault AnyMValue<W,MonadicValue<T>> nest()
MonadicValuenest in interface MonadicValue<T>default java.lang.String mkString()
Valuedefault <R> AnyMValue<W,R> zipWith(java.lang.Iterable<java.util.function.Function<? super T,? extends R>> fn)
default <R> AnyMValue<W,R> zipWithS(java.util.stream.Stream<java.util.function.Function<? super T,? extends R>> fn)
default <R> AnyMValue<W,R> zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super T,? extends R>> fn)
default <R> AnyMValue<W,R> retry(java.util.function.Function<? super T,? extends R> fn)
Transformable
given(serviceMock.applyHKT(anyInt())).willThrow(
new RuntimeException(new SocketException("First")),
new RuntimeException(new IOException("Second"))).willReturn(
"42");
String result = ReactiveSeq.of( 1, 2, 3)
.retry(serviceMock)
.firstValue();
//result = 42
retry in interface AnyM<W extends WitnessType<W>,T>retry in interface Transformable<T>fn - Function to retry if failsdefault <U> AnyMValue<W,org.jooq.lambda.tuple.Tuple2<T,U>> zipP(org.reactivestreams.Publisher<? extends U> other)
default <R> AnyMValue<W,R> retry(java.util.function.Function<? super T,? extends R> fn, int retries, long delay, java.util.concurrent.TimeUnit timeUnit)
Transformable
given(serviceMock.applyHKT(anyInt())).willThrow(
new RuntimeException(new SocketException("First")),
new RuntimeException(new IOException("Second"))).willReturn(
"42");
String result = ReactiveSeq.of( 1, 2, 3)
.retry(serviceMock, 7, 2, TimeUnit.SECONDS)
.firstValue();
//result = 42
retry in interface AnyM<W extends WitnessType<W>,T>retry in interface Transformable<T>fn - Function to retry if failsretries - Number of retriesdelay - Delay in TimeUnitstimeUnit - TimeUnit to use for delaydefault <S,U> AnyMValue<W,org.jooq.lambda.tuple.Tuple3<T,S,U>> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third)
Zippable
List<Tuple3<Integer, Integer, Character>> list = of(1, 2, 3, 4, 5, 6).zip3(of(100, 200, 300, 400), of('a', 'b', 'c')).collect(CyclopsCollectors.toList());
// [[1,100,'a'],[2,200,'b'],[3,300,'c']]
default <S,U,R> AnyMValue<W,R> zip3(java.lang.Iterable<? extends S> second, java.lang.Iterable<? extends U> third, Fn3<? super T,? super S,? super U,? extends R> fn3)
default <T2,T3,T4> AnyMValue<W,org.jooq.lambda.tuple.Tuple4<T,T2,T3,T4>> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth)
Zippable
List<Tuple4<Integer, Integer, Character, String>> list = of(1, 2, 3, 4, 5, 6).zip4(of(100, 200, 300, 400), of('a', 'b', 'c'), of("hello", "world"))
.collect(CyclopsCollectors.toList());
// [[1,100,'a',"hello"],[2,200,'b',"world"]]
default <T2,T3,T4,R> AnyMValue<W,R> zip4(java.lang.Iterable<? extends T2> second, java.lang.Iterable<? extends T3> third, java.lang.Iterable<? extends T4> fourth, Fn4<? super T,? super T2,? super T3,? super T4,? extends R> fn)
default <U> AnyMValue<W,U> ofType(java.lang.Class<? extends U> type)
Filters
// (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
default AnyMValue<W,T> filterNot(java.util.function.Predicate<? super T> fn)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
default AnyMValue<W,T> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
default <U> AnyMValue<W,U> cast(java.lang.Class<? extends U> type)
TransformableClassCastException.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)cast in interface AnyM<W extends WitnessType<W>,T>cast in interface Transformable<T>default <R> AnyMValue<W,R> trampoline(java.util.function.Function<? super T,? extends Trampoline<? extends R>> mapper)
Transformable
ReactiveSeq.of(10,20,30,40)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
Trampoline<Long> fibonacci(int i){
return fibonacci(i,1,0);
}
Trampoline<Long> fibonacci(int n, long a, long b) {
return n == 0 ? Trampoline.done(b) : Trampoline.more( ()->fibonacci(n-1, a+b, a));
}
55
6765
832040
102334155
ReactiveSeq.of(10_000,200_000,3_000_000,40_000_000)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
completes successfully
trampoline in interface AnyM<W extends WitnessType<W>,T>trampoline in interface Transformable<T>mapper - TCO Transformation functiondefault AnyMValue<W,T> filter(java.util.function.Predicate<? super T> p)
AnyM
AnyM.fromOptional(Optional.of(10)).filter(i->i<10);
//AnyM[Optional.zero()]
AnyM.fromStream(Stream.of(5,10)).filter(i->i<10);
//AnyM[Stream[5]]
default <R> AnyMValue<W,R> map(java.util.function.Function<? super T,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map in interface AnyM<W extends WitnessType<W>,T>map in interface MonadicValue<T>map in interface Transformable<T>fn - Transformation functiondefault AnyMValue<W,T> peek(java.util.function.Consumer<? super T> c)
AnyM
AnyM.fromCompletableFuture(CompletableFuture.supplyAsync(()->loadData())
.peek(System.out::println)
peek in interface AnyM<W extends WitnessType<W>,T>peek in interface Transformable<T>c - Consumer to accept current datadefault boolean isPresent()
isPresent in interface Convertable<T>default AnyMValue<W,java.util.List<T>> aggregate(AnyM<W,T> next)
AnyM
AnyM.fromStream(Stream.of(1,2,3,4))
.aggregate(fromEither5(Optional.of(5)))
AnyM[Stream[List[1,2,3,4,5]]
List<Integer> result = AnyM.fromStream(Stream.of(1,2,3,4))
.aggregate(fromEither5(Optional.of(5)))
.toSequence()
.flatten()
.toList();
assertThat(result,equalTo(Arrays.asList(1,2,3,4,5)));
default <R> AnyMValue<W,R> flatMapA(java.util.function.Function<? super T,? extends AnyM<W,? extends R>> fn)
default <R> AnyMValue<W,R> flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> fn)
MonadicValue
Maybe.just(1).map(i->i+2).flatMapI(i->Arrays.asList(()->i*3,20);
//Maybe[9]
flatMapI in interface AnyM<W extends WitnessType<W>,T>flatMapI in interface MonadicValue<T>fn - transformation functiondefault <R> AnyMValue<W,R> flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> fn)
MonadicValue
Future.ofResult(1).map(i->i+2).flatMapP(i->Flux.just(()->i*3,20);
//Future[9]
flatMapP in interface AnyM<W extends WitnessType<W>,T>flatMapP in interface MonadicValue<T>fn - transformation functiondefault <R> AnyMValue<W,R> flatMapS(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> fn)
flatMapS in interface AnyM<W extends WitnessType<W>,T>flatMapS in interface MonadicValue<T>default <R> AnyMValue<W,R> flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> fn)
MonadicValueOptional.flatMap(Function)
Eval.now(1).map(i->i+2).flatMap(i->Eval.later(()->i*3);
//Eval[9]
flatMap in interface MonadicValue<T>fn - transformation functiondefault T get()
get in interface Convertable<T>get in interface java.util.function.Supplier<T>default <T> AnyMValue<W,T> unit(T value)
AnyM
AnyM<Integer> ints = AnyM.fromList(Arrays.asList(1,2,3);
AnyM<String> string = ints.unit("hello");
default <T> AnyMValue<W,T> empty()
AnyM
Any<Integer> ints = AnyM.fromStream(Stream.of(1,2,3));
AnyM<Integer> zero=ints.zero();
default Xor<AnyMValue<W,T>,AnyMSeq<W,T>> matchable()
AnyM
AnyM<String> monad;
monad.matchable().visit(v->handleValue(v.get()),s->handleSequence(s.toList()));
default <T2,R> AnyMValue<W,R> combine(Value<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
MonadicValue
Maybe<Integer> some = Maybe.just(10);
just.combine(Eval.now(20), this::add);
//Some[30]
Maybe<Integer> none = Maybe.none();
none.combine(Eval.now(20), this::add);
//None
combine in interface MonadicValue<T>app - Value to combine with this one.fn - BiFunction to combine themdefault <T2,R> AnyMValue<W,R> zip(java.lang.Iterable<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zippabledefault <T2,R> AnyMValue<W,R> zipP(org.reactivestreams.Publisher<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zippabledefault java.util.Iterator<T> iterator()
default ReactiveSeq<T> stream()
default <T2,R1,R2,R3,R> AnyMValue<W,R> forEach4(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super T,? super R1,? super R2,? extends MonadicValue<R3>> value3, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach4(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->Maybe.none(),
(a,b,c,d)->a+b+c+d);
//Maybe.none
forEach4 in interface MonadicValue<T>value1 - Nested MonadicValue to iterate overvalue2 - Nested MonadicValue to iterate overvalue3 - Nested MonadicValue to iterate overyieldingFunction - Function with pointers to the current element from both
MonadicValue that generates the new elementsdefault <T2,R1,R2,R3,R> AnyMValue<W,R> forEach4(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super T,? super R1,? super R2,? extends MonadicValue<R3>> value3, Fn4<? super T,? super R1,? super R2,? super R3,java.lang.Boolean> filterFunction, Fn4<? super T,? super R1,? super R2,? super R3,? extends R> yieldingFunction)
MonadicValueMaybe.of(3)
.forEach4(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->Maybe.none(),
(a,b,c,d)->a+b+c<100,
(a,b,c,d)->a+b+c+d);
//Maybe.none
forEach4 in interface MonadicValue<T>value1 - Nested MonadicValue to iterate overvalue2 - Nested MonadicValue to iterate overvalue3 - Nested MonadicValue to iterate overfilterFunction - Filter to applyHKT over elements before passing non-filtered
values to the yielding functionyieldingFunction - Function with pointers to the current element from both
MonadicValue that generates the new elementsdefault <T2,R1,R2,R> AnyMValue<W,R> forEach3(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach3(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->a+b+c<100,
(a,b,c)->a+b+c);
//Maybe[32]
forEach3 in interface MonadicValue<T>value1 - Nested MonadicValue to iterate overvalue2 - Nested MonadicValue to iterate overyieldingFunction - Function with pointers to the current element from both
MonadicValue that generates the new elementsdefault <T2,R1,R2,R> AnyMValue<W,R> forEach3(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends MonadicValue<R2>> value2, Fn3<? super T,? super R1,? super R2,java.lang.Boolean> filterFunction, Fn3<? super T,? super R1,? super R2,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach3(a->Maybe.just(a+10),
(a,b)->Maybe.just(a+b),
(a,b,c)->a+b+c<100,
(a,b,c)->a+b+c);
//Maybe[32]
forEach3 in interface MonadicValue<T>value1 - Nested MonadicValue to iterate overvalue2 - Nested MonadicValue to iterate overfilterFunction - Filter to applyHKT over elements before passing non-filtered
values to the yielding functionyieldingFunction - Function with pointers to the current element from both
MonadicValue that generates the new elementsdefault <R1,R> AnyMValue<W,R> forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach2(a->Maybe.none(),
(a,b)->a+b);
//Maybe.none()
forEach2 in interface MonadicValue<T>value1 - Nested Monadic Type to iterate overyieldingFunction - Function with pointers to the current element from both
monad types that generates the new elementsdefault <R1,R> AnyMValue<W,R> forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
MonadicValue
Maybe.of(3)
.forEach2(a->Maybe.none(),
a->b-> a<3 && b>10,
(a,b)->a+b);
//Maybe.none()
forEach2 in interface MonadicValue<T>filterFunction - Filter to applyHKT over elements before passing non-filtered
values to the yielding functionyieldingFunction - Function with pointers to the current element from both
Streams that generates the new elementsdefault AnyMValue<W,T> combineEager(Monoid<T> monoid, MonadicValue<? extends T> v2)
MonadicValue
Monoid<Integer> add = Monoid.of(1,SemigroupK.intSum);
Maybe.of(10).combineEager(add,Maybe.none());
//Maybe[10]
Maybe.none().combineEager(add,Maybe.of(10));
//Maybe[10]
Maybe.none().combineEager(add,Maybe.none());
//Maybe.none()
Maybe.of(10).combineEager(add,Maybe.of(10));
//Maybe[20]
Monoid<Integer> firstNonNull = Monoid.of(null , SemigroupK.firstNonNull());
Maybe.of(10).combineEager(firstNonNull,Maybe.of(10));
//Maybe[10]
combineEager in interface MonadicValue<T>