T - Data type of element stored inside this Monadpublic interface MonadicValue<T> extends Value<T>, Unit<T>, Transformable<T>, Filters<T>, Zippable<T>
Value.ValueImpl<T>Convertable.SupplierToConvertable<T>Fn0.FunctionalOperations<R>, Fn0.Instances, Fn0.SupplierKind<R>| Modifier and Type | Method and Description |
|---|---|
default int |
arity() |
default <R> MonadicValue<R> |
coflatMap(java.util.function.Function<? super MonadicValue<T>,R> mapper)
Perform a coflatMap operation.
|
default <T2,R> MonadicValue<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 MonadicValue<T> |
combineEager(Monoid<T> monoid,
MonadicValue<? extends T> v2)
Eagerly combine two MonadicValues using the supplied monoid (@see ApplicativeFunctor for type appropraite i.e.
|
MonadicValue<T> |
filter(java.util.function.Predicate<? super T> predicate)
Keep only elements for which the supplied predicates hold
e.g.
|
<R> MonadicValue<R> |
flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> mapper)
A flattening transformation operation (@see
Optional.flatMap(Function) |
default <R> MonadicValue<R> |
flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)
A flattening transformation operation that takes the first value from the returned Iterable.
|
default <R> MonadicValue<R> |
flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
A flattening transformation operation that takes the first value from the returned Publisher.
|
default <R> MonadicValue<R> |
flatMapS(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> mapper) |
default <R1,R> MonadicValue<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> MonadicValue<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
|
<R> MonadicValue<R> |
map(java.util.function.Function<? super T,? extends R> fn)
Transform this functor using the supplied transformation function
|
default MonadicValue<MonadicValue<T>> |
nest()
cojoin pattern.
|
<T> MonadicValue<T> |
unit(T unit) |
default <T2,R> MonadicValue<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 <T2,R> MonadicValue<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
|
apply, generate, iterate, iterator, mkString, newSubscriber, of, stream, 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, xMatchcollect, fromSupplier, get, isPresent, orElse, orElseGet, orElseThrow, toCompletableFuture, toCompletableFutureAsync, toFuture, toFutureAsync, toOptional, toStream, visitandThen, fnTo, functionOps, future, lift, lift, liftF, liftOpt, liftTry, memoize, memoize, memoizeAsync, memoizeAsync, run, suspend, λ, λvzip, zip, zip3, zip3, zip4, zip4, zipP, zipS, zipS, zipWith, zipWithP, zipWithScast, peek, retry, retry, trampolinedefault int arity()
MonadicValue<T> filter(java.util.function.Predicate<? super T> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[3]
<T> MonadicValue<T> unit(T unit)
<R> MonadicValue<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 Transformable<T>fn - Transformation functiondefault <R> MonadicValue<R> coflatMap(java.util.function.Function<? super MonadicValue<T>,R> mapper)
Maybe.none().coflatMap(m -> m.isPresent() ? m.get() : 10);
//Maybe[10]
mapper - Mapping / transformation functiondefault MonadicValue<MonadicValue<T>> nest()
<R> MonadicValue<R> flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> mapper)
Optional.flatMap(Function)
Eval.now(1).map(i->i+2).flatMap(i->Eval.later(()->i*3);
//Eval[9]
mapper - transformation functiondefault <T2,R1,R2,R3,R> MonadicValue<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)
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
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> MonadicValue<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)
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
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> MonadicValue<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)
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]
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> MonadicValue<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)
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]
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> MonadicValue<R> forEach2(java.util.function.Function<? super T,? extends MonadicValue<R1>> value1, java.util.function.BiFunction<? super T,? super R1,? extends R> yieldingFunction)
Maybe.of(3)
.forEach2(a->Maybe.none(),
(a,b)->a+b);
//Maybe.none()
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> MonadicValue<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)
Maybe.of(3)
.forEach2(a->Maybe.none(),
a->b-> a<3 && b>10,
(a,b)->a+b);
//Maybe.none()
monad1 - Nested monadic type 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
Streams that generates the new elementsdefault MonadicValue<T> combineEager(Monoid<T> monoid, MonadicValue<? extends T> v2)
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]
monoid - v2 - default <R> MonadicValue<R> flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)
Maybe.just(1).map(i->i+2).flatMapI(i->Arrays.asList(()->i*3,20);
//Maybe[9]
mapper - transformation functiondefault <R> MonadicValue<R> flatMapS(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> mapper)
default <R> MonadicValue<R> flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
Future.ofResult(1).map(i->i+2).flatMapP(i->Flux.just(()->i*3,20);
//Future[9]
mapper - transformation functiondefault <T2,R> MonadicValue<R> combine(Value<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
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
app - Value to combine with this one.fn - BiFunction to combine themdefault <T2,R> MonadicValue<R> zip(java.lang.Iterable<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zippabledefault <T2,R> MonadicValue<R> zipP(org.reactivestreams.Publisher<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zippable