- Type Parameters:
A
- the input argument typeM
- theMonad
unification parameterMB
- the outputMonad
type
- All Superinterfaces:
Applicative<MB,
,Fn1<A, ?>> Cartesian<A,
,MB, Fn1<?, ?>> Cocartesian<A,
,MB, Fn1<?, ?>> Contravariant<A,
,Profunctor<?, MB, Fn1<?, ?>>> Fn1<A,
,MB> Functor<MB,
,Fn1<A, ?>> Monad<MB,
,Fn1<A, ?>> MonadReader<A,
,MB, Fn1<A, ?>> MonadRec<MB,
,Fn1<A, ?>> MonadWriter<A,
,MB, Fn1<A, ?>> Profunctor<A,
MB, Fn1<?, ?>>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface Kleisli<A,B,M extends Monad<?,M>,MB extends Monad<B,M>>
extends Fn1<A,MB>
The Kleisli arrow of a
Monad
, manifest as simply an Fn1
<A, MB>
. This can be
thought of as a fixed, portable Monad.flatMap(Fn1)
.-
Method Summary
Modifier and TypeMethodDescriptionContravariantly mapA <- B
.Contravariantly map over the argument to this function, producing a function that takes the new argument type, and produces the same result.discardR
(Applicative<C, Fn1<A, ?>> appB) Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
.Adapt a compatible function into aKleisli
arrow.
-
Method Details
-
andThen
-
compose
-
discardR
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
. This is generally useful for sequentially performing side-effects.- Specified by:
discardR
in interfaceApplicative<A,
B> - Specified by:
discardR
in interfaceFn1<A,
B> - Specified by:
discardR
in interfaceMonad<A,
B> - Specified by:
discardR
in interfaceMonadReader<A,
B, M extends Monad<?, M>> - Specified by:
discardR
in interfaceMonadRec<A,
B> - Specified by:
discardR
in interfaceMonadWriter<A,
B, M extends Monad<?, M>> - Type Parameters:
C
- the type of appB's parameter- Parameters:
appB
- the other Applicative- Returns:
- this Applicative
-
contraMap
Contravariantly mapA <- B
.- Specified by:
contraMap
in interfaceCartesian<A,
B, M extends Monad<?, M>> - Specified by:
contraMap
in interfaceCocartesian<A,
B, M extends Monad<?, M>> - Specified by:
contraMap
in interfaceContravariant<A,
B> - Specified by:
contraMap
in interfaceFn1<A,
B> - Specified by:
contraMap
in interfaceProfunctor<A,
B, M extends Monad<?, M>> - Type Parameters:
Z
- the new parameter type- Parameters:
fn
- the mapping function- Returns:
- the mapped Contravariant functor instance
-
diMapL
Contravariantly map over the argument to this function, producing a function that takes the new argument type, and produces the same result.- Specified by:
diMapL
in interfaceCartesian<A,
B, M extends Monad<?, M>> - Specified by:
diMapL
in interfaceCocartesian<A,
B, M extends Monad<?, M>> - Specified by:
diMapL
in interfaceFn1<A,
B> - Specified by:
diMapL
in interfaceProfunctor<A,
B, M extends Monad<?, M>> - Type Parameters:
Z
- the new argument type- Parameters:
fn
- the contravariant argument mapping function- Returns:
- an
Fn1
<Z, B>
-
kleisli
static <A,B, Kleisli<A,M extends Monad<?, M>, MB extends Monad<B, M>> B, kleisliM, MB> (Fn1<? super A, ? extends MB> fn) Adapt a compatible function into aKleisli
arrow.
-