T - Type of value storable in this Evalpublic interface Eval<T> extends To<Eval<T>>, MonadicValue<T>, Higher<Witness.eval,T>
public void odd(){
System.out.println(even(Eval.now(200000)).get());
}
public Eval<String> odd(Eval<Integer> n ) {
return n.flatMap(x->even(Eval.now(x-1)));
}
public Eval<String> even(Eval<Integer> n ) {
return n.flatMap(x->{
return x<=0 ? Eval.now("done") : odd(Eval.now(x-1));
});
}
| Modifier and Type | Interface and Description |
|---|---|
static class |
Eval.CompletableEval<ORG,T2> |
static class |
Eval.Instances
Companion class for creating Type Class instances for working with Evals
|
static class |
Eval.Module |
Value.ValueImpl<T>Convertable.SupplierToConvertable<T>Fn0.FunctionalOperations<R>, Fn0.SupplierKind<R>| Modifier and Type | Method and Description |
|---|---|
static <T,R> Eval<R> |
accumulate(CollectionX<Eval<T>> evals,
java.util.function.Function<? super T,R> mapper,
Monoid<R> reducer)
Sequence and reduce a CollectionX of Evals into an Eval with a reduced value
|
static <T,R> Eval<R> |
accumulate(CollectionX<Eval<T>> evals,
Reducer<R> reducer)
Sequence and reduce a CollectionX of Evals into an Eval with a reduced value
|
static <T> Eval<T> |
accumulate(Monoid<T> reducer,
CollectionX<Eval<T>> evals)
Sequence and reduce a CollectionX of Evals into an Eval with a reduced value
|
default Active<Witness.eval,T> |
allTypeclasses() |
static <T> Eval<T> |
always(java.util.function.Supplier<T> value)
Lazily create an Eval from the specified Supplier.
|
default AnyM<Witness.eval,T> |
anyM() |
static <T> Eval<T> |
async(java.util.concurrent.Executor ex,
java.util.function.Supplier<T> s) |
default <U> Eval<U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a reactiveStream to a given type, possibly throwing a
ClassCastException. |
static <T> Eval<T> |
coeval(Future<Eval<T>> pub) |
default <R> Eval<R> |
coflatMap(java.util.function.Function<? super MonadicValue<T>,R> mapper)
Perform a coflatMap operation.
|
default <T2,R> Eval<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 Eval<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 <W1> Coproduct<W1,Witness.eval,T> |
coproduct(InstanceDefinitions<W1> def2) |
static <T> Eval<T> |
defer(java.util.function.Supplier<Eval<T>> value) |
static <T> Eval.CompletableEval<T,T> |
eval()
Create a reactiveBuffer CompletableEval
|
default Maybe<T> |
filter(java.util.function.Predicate<? super T> pred)
Keep only elements for which the supplied predicates hold
e.g.
|
default Maybe<T> |
filterNot(java.util.function.Predicate<? super T> fn)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
<R> Eval<R> |
flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> mapper)
A flattening transformation operation (@see
Optional.flatMap(Function) |
default <R> Eval<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> Eval<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> Eval<R> |
flatMapS(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> mapper) |
default <R1,R> Eval<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> Eval<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
|
static <T> Eval<T> |
fromFuture(Future<T> pub) |
static <T> Eval<T> |
fromIterable(java.lang.Iterable<T> iterable)
Create an Eval instance from an Iterable
|
static <T> Eval<T> |
fromPublisher(org.reactivestreams.Publisher<T> pub)
Create an Eval instance from a reactiveBuffer-streams publisher
|
T |
get() |
static <T> Cokleisli<Witness.eval,T,Eval<T>> |
kindCokleisli() |
static <T> Kleisli<Witness.eval,Eval<T>,T> |
kindKleisli() |
static <T> Eval<T> |
later(java.util.function.Supplier<T> value)
Lazily create an Eval from the specified Supplier.
|
default <W extends WitnessType<W>> |
liftM(W witness) |
<R> Eval<R> |
map(java.util.function.Function<? super T,? extends R> mapper)
Transform this functor using the supplied transformation function
|
default <W2,R> Nested<Witness.eval,W2,R> |
mapM(java.util.function.Function<? super T,? extends Higher<W2,R>> fn,
InstanceDefinitions<W2> defs) |
static <R> Eval<R> |
narrow(Eval<? extends R> broad)
Narrow covariant type parameter
|
static <T> Eval<T> |
narrowK(Higher<Witness.eval,T> future)
Convert the raw Higher Kinded Type for Evals types into the Eval interface
|
default Eval<MonadicValue<T>> |
nest()
cojoin pattern.
|
static <W1,T> Nested<Witness.eval,W1,T> |
nested(Eval<Higher<W1,T>> nested,
InstanceDefinitions<W1> def2) |
default Maybe<T> |
notNull()
Filter elements retaining only values which are not null
|
static <T> Eval<T> |
now(T value)
Create an Eval with the value specified
|
default <U> Maybe<U> |
ofType(java.lang.Class<? extends U> type)
Keep only those elements in a reactiveStream that are of a given type.
|
default Eval<T> |
peek(java.util.function.Consumer<? super T> c)
Peek at the current value of this Transformable, without transforming it
|
default <W1> Product<Witness.eval,W1,T> |
product(Active<W1,T> active) |
default <R> Eval<R> |
retry(java.util.function.Function<? super T,? extends R> fn)
Retry a transformation if it fails.
|
default <R> Eval<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.
|
static <T> Eval<ListX<T>> |
sequence(CollectionX<Eval<T>> evals)
Turn a toX of Evals into a singleUnsafe Eval with a List of values.
|
static <T> Eval<ReactiveSeq<T>> |
sequence(java.util.stream.Stream<? extends Eval<T>> evals)
Turn a Stream of Evals into a singleUnsafe Eval with a Stream of values.
|
default org.pcollections.PVector<java.util.function.Function<java.lang.Object,java.lang.Object>> |
steps() |
default Maybe<T> |
toMaybe() |
default Trampoline<T> |
toTrampoline() |
default <R> Eval<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
|
<T> Eval<T> |
unit(T unit) |
default <R> R |
visit(java.util.function.Function<? super T,? extends R> present,
java.util.function.Supplier<? extends R> absent)
The provided function is executed with the value stored in this Visitable if one is present,
otherwise the provided Supplier is executed instead.
|
static <T> Higher<Witness.eval,T> |
widen(Eval<T> narrow) |
default Eval<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> Eval<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 <U> Eval<org.jooq.lambda.tuple.Tuple2<T,U>> |
zip(java.lang.Iterable<? extends U> other)
Zip (combine) this Zippable with the supplied Iterable combining both into a Tuple2
|
default <S,U> Eval<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> Eval<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> Eval<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> Eval<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> Eval<org.jooq.lambda.tuple.Tuple2<T,U>> |
zipP(org.reactivestreams.Publisher<? extends U> other) |
default <U> Eval<org.jooq.lambda.tuple.Tuple2<T,U>> |
zipS(java.util.stream.Stream<? extends U> other)
Zip (combine) this Zippable with the supplied Stream combining both into a Tuple2
|
default <U,R> Eval<R> |
zipS(java.util.stream.Stream<? extends U> other,
java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zip (combine) this Zippable with the supplied Stream, using the supplied combining function
|
default <R> Eval<R> |
zipWith(java.lang.Iterable<java.util.function.Function<? super T,? extends R>> fn) |
default <R> Eval<R> |
zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super T,? extends R>> fn) |
default <R> Eval<R> |
zipWithS(java.util.stream.Stream<java.util.function.Function<? super T,? extends R>> fn) |
arityapply, generate, iterate, iterator, mkString, newSubscriber, of, stream, subscribe, test, toEither, toEval, toEvalAlways, toEvalLater, toEvalNow, toIor, toLeft, 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, isPresent, orElse, orElseGet, orElseThrow, toCompletableFuture, toCompletableFutureAsync, toFuture, toFutureAsync, toOptional, toStreamstatic <T> Kleisli<Witness.eval,Eval<T>,T> kindKleisli()
static <T> Higher<Witness.eval,T> widen(Eval<T> narrow)
static <T> Cokleisli<Witness.eval,T,Eval<T>> kindCokleisli()
static <W1,T> Nested<Witness.eval,W1,T> nested(Eval<Higher<W1,T>> nested, InstanceDefinitions<W1> def2)
default <W1> Product<Witness.eval,W1,T> product(Active<W1,T> active)
default <W1> Coproduct<W1,Witness.eval,T> coproduct(InstanceDefinitions<W1> def2)
default Active<Witness.eval,T> allTypeclasses()
default <W2,R> Nested<Witness.eval,W2,R> mapM(java.util.function.Function<? super T,? extends Higher<W2,R>> fn, InstanceDefinitions<W2> defs)
static <T> Eval<T> async(java.util.concurrent.Executor ex, java.util.function.Supplier<T> s)
default <W extends WitnessType<W>> EvalT<W,T> liftM(W witness)
default AnyM<Witness.eval,T> anyM()
static <T> Eval<T> narrowK(Higher<Witness.eval,T> future)
future - HKT encoded list into a OptionalTypestatic <T> Eval<T> fromPublisher(org.reactivestreams.Publisher<T> pub)
Eval<Integer> e = Eval.fromPublisher(Mono.just(10));
//Eval[10]
pub - Publisher to create the Eval fromstatic <T> Eval.CompletableEval<T,T> eval()
CompletableEval<Integer,Integer> completable = Eval.eval();
Eval<Integer> mapped = completable.map(i->i*2)
.flatMap(i->Eval.later(()->i+1));
completable.complete(5);
mapped.printOut();
//11
T - Data input type to the Evalstatic <T> Eval<T> fromIterable(java.lang.Iterable<T> iterable)
Eval<Integer> e = Eval.fromIterable(Arrays.asList(10));
//Eval[10]
iterable - to create the Eval fromstatic <T> Eval<T> now(T value)
Eval<Integer> e = Eval.now(10);
//Eval[10]
value - of Evalstatic <T> Eval<T> later(java.util.function.Supplier<T> value)
Eval<Integer> e = Eval.later(()->10)
.map(i->i*2);
//Eval[20] - maybe so will not be executed until the value is accessed
value - Supplier to (lazily) populate this Evalstatic <T> Eval<T> always(java.util.function.Supplier<T> value)
Eval<Integer> e = Eval.always(()->10)
.map(i->i*2);
//Eval[20] - maybe so will not be executed until the value is accessed
value - Supplier to (lazily) populate this Evalstatic <T> Eval<ListX<T>> sequence(CollectionX<Eval<T>> evals)
Eval<ListX<Integer>> maybes =Eval.sequence(ListX.of(Eval.now(10),Eval.now(1)));
//Eval.now(ListX.of(10,1)));
evals - Collection of evals to convert into a singleUnsafe eval with a List of valuesstatic <T> Eval<ReactiveSeq<T>> sequence(java.util.stream.Stream<? extends Eval<T>> evals)
Eval<ReactiveSeq<Integer>> maybes =Eval.sequence(Stream.of(Eval.now(10),Eval.now(1)));
//Eval.now(ReactiveSeq.of(10,1)));
evals - Collection of evals to convert into a singleUnsafe eval with a List of valuesstatic <T,R> Eval<R> accumulate(CollectionX<Eval<T>> evals, Reducer<R> reducer)
Eval<PersistentSetX<Integer>> accumulated = Eval.accumulate(ListX.of(just,Eval.now(1)),Reducers.toPersistentSetX());
//Eval.now(PersistentSetX.of(10,1)))
evals - Collection of Evals to accumulatereducer - Reducer to fold nest values intostatic <T,R> Eval<R> accumulate(CollectionX<Eval<T>> evals, java.util.function.Function<? super T,R> mapper, Monoid<R> reducer)
Eval<String> evals =Eval.accumulate(ListX.of(just,Eval.later(()->1)),i->""+i,Monoids.stringConcat);
//Eval.now("101")
evals - Collection of Evals to accumulatemapper - Funtion to map Eval contents to type required by Semigroup accumulatorreducer - Combiner function to applyHKT to converted valuesstatic <T> Eval<T> accumulate(Monoid<T> reducer, CollectionX<Eval<T>> evals)
Eval<Integer> maybes =Eval.accumulate(Monoids.intSum,ListX.of(just,Eval.now(1)));
//Eval.now(11)
evals - Collection of Evals to accumulatereducer - Combiner function to applyHKT to converted valuesdefault Trampoline<T> toTrampoline()
<T> Eval<T> unit(T unit)
<R> Eval<R> map(java.util.function.Function<? super T,? extends R> mapper)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map in interface MonadicValue<T>map in interface Transformable<T>mapper - Transformation function<R> Eval<R> flatMap(java.util.function.Function<? super T,? extends MonadicValue<? extends R>> mapper)
MonadicValueOptional.flatMap(Function)
Eval.now(1).map(i->i+2).flatMap(i->Eval.later(()->i*3);
//Eval[9]
flatMap in interface MonadicValue<T>mapper - transformation functiondefault org.pcollections.PVector<java.util.function.Function<java.lang.Object,java.lang.Object>> steps()
default <R> Eval<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 Eval<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>default <R> Eval<R> flatMapI(java.util.function.Function<? super T,? extends java.lang.Iterable<? extends R>> mapper)
MonadicValue
Maybe.just(1).map(i->i+2).flatMapI(i->Arrays.asList(()->i*3,20);
//Maybe[9]
flatMapI in interface MonadicValue<T>mapper - transformation functiondefault <R> Eval<R> flatMapP(java.util.function.Function<? super T,? extends org.reactivestreams.Publisher<? extends R>> mapper)
MonadicValue
Future.ofResult(1).map(i->i+2).flatMapP(i->Flux.just(()->i*3,20);
//Future[9]
flatMapP in interface MonadicValue<T>mapper - transformation functiondefault Eval<T> zip(java.util.function.BinaryOperator<Zippable<T>> combiner, Zippable<T> app)
Zippablezip 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 Eval<MonadicValue<T>> nest()
MonadicValuenest in interface MonadicValue<T>T get()
get in interface Convertable<T>get in interface java.util.function.Supplier<T>default <U> Maybe<U> ofType(java.lang.Class<? extends U> type)
Filters
// (1, 2, 3) ReactiveSeq.of(1, "a", 2, "b",3).ofType(Integer.class)
default Maybe<T> filterNot(java.util.function.Predicate<? super T> fn)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
default Maybe<T> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
default Maybe<T> filter(java.util.function.Predicate<? super T> pred)
Filters
of(1,2,3).filter(i->i>2);
//[3]
default <U> Eval<U> cast(java.lang.Class<? extends U> type)
TransformableClassCastException.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)cast in interface Transformable<T>default Eval<T> peek(java.util.function.Consumer<? super T> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
peek in interface Transformable<T>c - Consumer that recieves each element from this Transformabledefault <R> Eval<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 Transformable<T>mapper - TCO Transformation functiondefault <R> R visit(java.util.function.Function<? super T,? extends R> present, java.util.function.Supplier<? extends R> absent)
Visitablestatic <R> Eval<R> narrow(Eval<? extends R> broad)
broad - Eval with covariant type parameterdefault <T2,R> Eval<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> Eval<R> zip(java.lang.Iterable<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zippabledefault <T2,R> Eval<R> zipP(org.reactivestreams.Publisher<? extends T2> app, java.util.function.BiFunction<? super T,? super T2,? extends R> fn)
Zippabledefault <U,R> Eval<R> zipS(java.util.stream.Stream<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends R> zipper)
Zippabledefault <U> Eval<org.jooq.lambda.tuple.Tuple2<T,U>> zipS(java.util.stream.Stream<? extends U> other)
Zippabledefault <U> Eval<org.jooq.lambda.tuple.Tuple2<T,U>> zip(java.lang.Iterable<? extends U> other)
Zippabledefault <R> Eval<R> zipWith(java.lang.Iterable<java.util.function.Function<? super T,? extends R>> fn)
default <R> Eval<R> zipWithS(java.util.stream.Stream<java.util.function.Function<? super T,? extends R>> fn)
default <R> Eval<R> zipWithP(org.reactivestreams.Publisher<java.util.function.Function<? super T,? extends R>> fn)
default <R> Eval<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 Transformable<T>fn - Function to retry if failsdefault <U> Eval<org.jooq.lambda.tuple.Tuple2<T,U>> zipP(org.reactivestreams.Publisher<? extends U> other)
default <R> Eval<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 Transformable<T>fn - Function to retry if failsretries - Number of retriesdelay - Delay in TimeUnitstimeUnit - TimeUnit to use for delaydefault <S,U> Eval<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> Eval<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> Eval<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> Eval<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 <R> Eval<R> flatMapS(java.util.function.Function<? super T,? extends java.util.stream.Stream<? extends R>> mapper)
flatMapS in interface MonadicValue<T>default <T2,R1,R2,R3,R> Eval<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> Eval<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> Eval<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> Eval<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> Eval<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> Eval<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 elements