W
- Monad kindT
- Function input typeR
- Function return type
(inside monad e.g. Kleisli[stream,String,Integer] represents a function that takes a String and returns a Stream of Integers)@FunctionalInterface public interface Kleisli<W extends WitnessType<W>,T,R> extends Fn1<T,AnyM<W,R>>, Transformable<R>
Modifier and Type | Interface and Description |
---|---|
static class |
Kleisli.µ |
Fn1.FunctionalOperations<T1,R>
Modifier and Type | Method and Description |
---|---|
default <A> Kleisli<W,A,R> |
compose(Kleisli<W,A,T> kleisli) |
default <T2> Kleisli<W,Xor<T,T2>,R> |
fanIn(Kleisli<W,T2,R> fanIn) |
default <__> Kleisli<W,org.jooq.lambda.tuple.Tuple2<T,__>,org.jooq.lambda.tuple.Tuple2<R,__>> |
firstK() |
default <R1> Kleisli<W,T,R1> |
flatMap(java.util.function.Function<? super R,? extends Kleisli<W,T,R1>> mapper)
Compose functions that return monads.
|
default <R1> Kleisli<W,T,R1> |
flatMapA(java.util.function.Function<? super R,? extends AnyM<W,? extends R1>> mapper) |
default <R1,R4> Kleisli<W,T,R4> |
forEach2(java.util.function.Function<? super R,java.util.function.Function<? super T,? extends AnyM<W,? extends R1>>> value2,
java.util.function.BiFunction<? super R,? super R1,? extends R4> yieldingFunction) |
default <R1,R2,R4> Kleisli<W,T,R4> |
forEach3(java.util.function.Function<? super R,java.util.function.Function<? super T,? extends AnyM<W,? extends R1>>> value2,
java.util.function.BiFunction<? super R,? super R1,java.util.function.Function<? super T,? extends AnyM<W,? extends R2>>> value3,
Fn3<? super R,? super R1,? super R2,? extends R4> yieldingFunction) |
default <R1,R2,R3,R4> |
forEach4(java.util.function.Function<? super R,java.util.function.Function<? super T,? extends AnyM<W,? extends R1>>> value2,
java.util.function.BiFunction<? super R,? super R1,java.util.function.Function<? super T,? extends AnyM<W,? extends R2>>> value3,
Fn3<? super R,? super R1,? super R2,java.util.function.Function<? super T,? extends AnyM<W,? extends R3>>> value4,
Fn4<? super R,? super R1,? super R2,? super R3,? extends R4> yieldingFunction) |
static <T,R,W extends WitnessType<W>> |
kleisli(java.util.function.Function<? super T,? extends AnyM<W,? extends R>> fn) |
default <__> Kleisli<W,Xor<T,__>,Xor<R,__>> |
leftK(W type) |
static <T,R,W extends WitnessType<W>> |
lift(java.util.function.Function<? super T,? extends R> fn,
W type) |
default Kleisli<W,T,R> |
local(java.util.function.Function<? super R,? extends R> local) |
default <R1> Kleisli<W,T,R1> |
map(java.util.function.Function<? super R,? extends R1> mapper)
Transform this functor using the supplied transformation function
|
default <T2,R2> Kleisli<W,Xor<T,T2>,Xor<R,R2>> |
merge(Kleisli<W,T2,R2> merge,
W type) |
static <T,W extends WitnessType<W>,R> |
narrow(java.util.function.Function<? super T,? extends AnyM<W,? extends R>> fn) |
default <__> Kleisli<W,Xor<__,T>,Xor<__,R>> |
rightK(W type) |
default <__> Kleisli<W,org.jooq.lambda.tuple.Tuple2<__,T>,org.jooq.lambda.tuple.Tuple2<__,R>> |
secondK() |
default <R2> Kleisli<W,T,R2> |
then(Kleisli<W,R,R2> kleisli) |
after, andThen, andThen, apply, before, bind, compose, fanIn, firstFn, functionOps, leftFn, lift, lift, liftF, liftOpt, liftTry, memoize, memoize, memoizeAsync, memoizeAsync, merge, narrow, product, product, product, reader, rightFn, secondFn, λ, λv
apply, applyPartially, applyPartially, curry, curry, from, toFunction
cast, peek, retry, retry, trampoline
default <R1> Kleisli<W,T,R1> map(java.util.function.Function<? super R,? extends R1> mapper)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map
in interface Transformable<R>
mapper
- Transformation functiondefault <R1> Kleisli<W,T,R1> flatMapA(java.util.function.Function<? super R,? extends AnyM<W,? extends R1>> mapper)
default <R1> Kleisli<W,T,R1> flatMap(java.util.function.Function<? super R,? extends Kleisli<W,T,R1>> mapper)
import cyclops.monads.Witness.reactiveSeq;
import static cyclops.monads.Kleisli.kleisli;
Kleisli<reactiveSeq, Integer, Integer> k1 = kleisli(t -> ReactiveSeq.iterate(0,i->i<t, i->i+1)
.anyM(), reactiveSeq.INSTANCE);
k1.flatMap(i-> kleisli(t-> ReactiveSeq.of(t+i)
.anyM(), reactiveSeq.INSTANCE))
.apply(10)
.forEach(System.out::println);
10
11
12
13
14
15
16
17
18
19
R1
- mapper
- default <__> Kleisli<W,org.jooq.lambda.tuple.Tuple2<T,__>,org.jooq.lambda.tuple.Tuple2<R,__>> firstK()
default <__> Kleisli<W,org.jooq.lambda.tuple.Tuple2<__,T>,org.jooq.lambda.tuple.Tuple2<__,R>> secondK()
default <R1,R2,R3,R4> Kleisli<W,T,R4> forEach4(java.util.function.Function<? super R,java.util.function.Function<? super T,? extends AnyM<W,? extends R1>>> value2, java.util.function.BiFunction<? super R,? super R1,java.util.function.Function<? super T,? extends AnyM<W,? extends R2>>> value3, Fn3<? super R,? super R1,? super R2,java.util.function.Function<? super T,? extends AnyM<W,? extends R3>>> value4, Fn4<? super R,? super R1,? super R2,? super R3,? extends R4> yieldingFunction)
default <R1,R2,R4> Kleisli<W,T,R4> forEach3(java.util.function.Function<? super R,java.util.function.Function<? super T,? extends AnyM<W,? extends R1>>> value2, java.util.function.BiFunction<? super R,? super R1,java.util.function.Function<? super T,? extends AnyM<W,? extends R2>>> value3, Fn3<? super R,? super R1,? super R2,? extends R4> yieldingFunction)
default <R1,R4> Kleisli<W,T,R4> forEach2(java.util.function.Function<? super R,java.util.function.Function<? super T,? extends AnyM<W,? extends R1>>> value2, java.util.function.BiFunction<? super R,? super R1,? extends R4> yieldingFunction)
static <T,R,W extends WitnessType<W>> Kleisli<W,T,R> kleisli(java.util.function.Function<? super T,? extends AnyM<W,? extends R>> fn)
static <T,R,W extends WitnessType<W>> Kleisli<W,T,R> lift(java.util.function.Function<? super T,? extends R> fn, W type)
static <T,W extends WitnessType<W>,R> Fn1<T,AnyM<W,R>> narrow(java.util.function.Function<? super T,? extends AnyM<W,? extends R>> fn)