T - Type of data stored inside the nested Future(s)public final class ReaderT<W extends WitnessType<W>,T,R> extends java.lang.Object implements To<ReaderT<W,T,R>>, Transformable<R>, Fn1<T,R>
Fn1.FunctionalOperations<T1,R>| Modifier and Type | Method and Description |
|---|---|
R |
apply(T a) |
<U> ReaderT<W,T,U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a reactiveStream to a given type, possibly throwing a
ClassCastException. |
boolean |
equals(java.lang.Object o) |
<B> ReaderT<W,T,B> |
flatMap(java.util.function.Function<? super R,? extends Reader<T,B>> f) |
<B> ReaderT<W,T,B> |
flatMapT(java.util.function.Function<? super R,ReaderT<W,T,B>> f) |
<R1,R4> ReaderT<W,T,R4> |
forEach2(java.util.function.Function<? super R,java.util.function.Function<T,R1>> value2,
java.util.function.BiFunction<? super R,? super R1,? extends R4> yieldingFunction) |
<R1,B> ReaderT<W,T,B> |
forEach2M(java.util.function.Function<? super R,? extends ReaderT<W,T,R1>> value1,
java.util.function.BiFunction<? super R,? super R1,? extends B> yieldingFunction) |
<R1,R2,R4> ReaderT<W,T,R4> |
forEach3(java.util.function.Function<? super R,? extends java.util.function.Function<T,R1>> value2,
java.util.function.BiFunction<? super R,? super R1,? extends java.util.function.Function<T,R2>> value3,
Fn3<? super R,? super R1,? super R2,? extends R4> yieldingFunction) |
<T2,R1,R2,B> |
forEach3M(java.util.function.Function<? super R,? extends ReaderT<W,T,R1>> value1,
java.util.function.BiFunction<? super R,? super R1,? extends ReaderT<W,T,R2>> value2,
Fn3<? super R,? super R1,? super R2,? extends B> yieldingFunction) |
<R1,R2,R3,R4> |
forEach4(java.util.function.Function<? super R,? extends java.util.function.Function<T,R1>> value2,
java.util.function.BiFunction<? super R,? super R1,? extends java.util.function.Function<T,R2>> value3,
Fn3<? super R,? super R1,? super R2,? extends java.util.function.Function<T,R3>> value4,
Fn4<? super R,? super R1,? super R2,? super R3,? extends R4> yieldingFunction) |
<T2,R1,R2,R3,B> |
forEach4M(java.util.function.Function<? super R,? extends ReaderT<W,T,R1>> value1,
java.util.function.BiFunction<? super R,? super R1,? extends ReaderT<W,T,R2>> value2,
Fn3<? super R,? super R1,? super R2,? extends ReaderT<W,T,R3>> value3,
Fn4<? super R,? super R1,? super R2,? super R3,? extends B> yieldingFunction) |
int |
hashCode() |
<B> ReaderT<W,T,B> |
map(java.util.function.Function<? super R,? extends B> f)
Map the wrapped Future
|
java.lang.String |
mkString() |
static <W extends WitnessType<W>,T,R> |
of(AnyM<W,Reader<T,R>> monads)
Construct an FutureT from an AnyM that wraps a monad containing Futures
|
ReaderT<W,T,R> |
peek(java.util.function.Consumer<? super R> peek)
Peek at the current value of the Future
|
java.lang.String |
toString() |
<R2> ReaderT<W,T,R2> |
trampoline(java.util.function.Function<? super R,? extends Trampoline<? extends R2>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
AnyM<W,Reader<T,R>> |
unwrap() |
<R2> R2 |
unwrapTo(java.util.function.Function<? super AnyM<W,Reader<T,R>>,? extends R2> fn) |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitretry, retryafter, always, andThen, andThen, applyLazy, before, bind, compose, fanIn, firstFn, functionOps, later, leftFn, lift, lift, liftAnyM, liftF, liftNT, liftOpt, liftTry, memoize, memoize, memoizeAsync, memoizeAsync, merge, narrow, now, product, product, product, reader, rightFn, secondFn, λ, λvpublic <R2> R2 unwrapTo(java.util.function.Function<? super AnyM<W,Reader<T,R>>,? extends R2> fn)
public ReaderT<W,T,R> peek(java.util.function.Consumer<? super R> peek)
FutureT.of(AnyM.fromStream(Arrays.asFuture(10))
.peek(System.out::println);
//prints 10
peek in interface Transformable<R>peek - Consumer to accept current value of Futurepublic <B> ReaderT<W,T,B> map(java.util.function.Function<? super R,? extends B> f)
FutureT.of(AnyM.fromStream(Arrays.asFuture(10))
.map(t->t=t+1);
//FutureT<AnyMSeq<Stream<Future[11]>>>
map in interface Transformable<R>f - Mapping function for the wrapped Futurepublic <B> ReaderT<W,T,B> flatMap(java.util.function.Function<? super R,? extends Reader<T,B>> f)
public <B> ReaderT<W,T,B> flatMapT(java.util.function.Function<? super R,ReaderT<W,T,B>> f)
public static <W extends WitnessType<W>,T,R> ReaderT<W,T,R> of(AnyM<W,Reader<T,R>> monads)
monads - AnyM that contains a monad wrapping an Futurepublic java.lang.String toString()
toString in class java.lang.Objectpublic <T2,R1,R2,R3,B> ReaderT<W,T,B> forEach4M(java.util.function.Function<? super R,? extends ReaderT<W,T,R1>> value1, java.util.function.BiFunction<? super R,? super R1,? extends ReaderT<W,T,R2>> value2, Fn3<? super R,? super R1,? super R2,? extends ReaderT<W,T,R3>> value3, Fn4<? super R,? super R1,? super R2,? super R3,? extends B> yieldingFunction)
public <T2,R1,R2,B> ReaderT<W,T,B> forEach3M(java.util.function.Function<? super R,? extends ReaderT<W,T,R1>> value1, java.util.function.BiFunction<? super R,? super R1,? extends ReaderT<W,T,R2>> value2, Fn3<? super R,? super R1,? super R2,? extends B> yieldingFunction)
public <R1,B> ReaderT<W,T,B> forEach2M(java.util.function.Function<? super R,? extends ReaderT<W,T,R1>> value1, java.util.function.BiFunction<? super R,? super R1,? extends B> yieldingFunction)
public <R1,R2,R3,R4> ReaderT<W,T,R4> forEach4(java.util.function.Function<? super R,? extends java.util.function.Function<T,R1>> value2, java.util.function.BiFunction<? super R,? super R1,? extends java.util.function.Function<T,R2>> value3, Fn3<? super R,? super R1,? super R2,? extends java.util.function.Function<T,R3>> value4, Fn4<? super R,? super R1,? super R2,? super R3,? extends R4> yieldingFunction)
public <R1,R2,R4> ReaderT<W,T,R4> forEach3(java.util.function.Function<? super R,? extends java.util.function.Function<T,R1>> value2, java.util.function.BiFunction<? super R,? super R1,? extends java.util.function.Function<T,R2>> value3, Fn3<? super R,? super R1,? super R2,? extends R4> yieldingFunction)
public <R1,R4> ReaderT<W,T,R4> forEach2(java.util.function.Function<? super R,java.util.function.Function<T,R1>> value2, java.util.function.BiFunction<? super R,? super R1,? extends R4> yieldingFunction)
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic java.lang.String mkString()
public <U> ReaderT<W,T,U> cast(java.lang.Class<? extends U> type)
TransformableClassCastException.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)cast in interface Transformable<R>public <R2> ReaderT<W,T,R2> trampoline(java.util.function.Function<? super R,? extends Trampoline<? extends R2>> 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<R>mapper - TCO Transformation function