arrow-core-data / arrow.typeclasses / Monad


interface Monad<F> : Selective<F>

Monad abstract over the ability to declare sequential computations that are dependent in the order or the results of previous computations.

Given a type constructor F with a value of A we can compose multiple operations of type Kind<F, ?> where ? denotes a value being transformed.

This is true for all type constructors that can support the Monad type class including and not limited to IO, ObservableK, Option, Either, List

The Monad Tutorial


fx Entry point for monad bindings which enables for comprehension. The underlying implementation is based on coroutines. A coroutine is initiated and suspended inside MonadThrowContinuation yielding to Monad.flatMap. Once all the flatMap binds are completed the underlying monad is returned from the act of executing the coroutineopen val fx: MonadFx<F>


ap open fun <A, B> Kind<F, A>.ap(ff: Kind<F, (A) -> B>): Kind<F, B>
apTap Given two actions, it performs them sequentially. Discards the result of the second fun <A, B> Kind<F, A>.apTap(fb: Kind<F, B>): Kind<F, A>
effectM open fun <A, B> Kind<F, A>.~~effectM~~(f: (A) -> Kind<F, B>): Kind<F, A>
flatMap abstract fun <A, B> Kind<F, A>.flatMap(f: (A) -> Kind<F, B>): Kind<F, B>
flatTap open fun <A, B> Kind<F, A>.flatTap(f: (A) -> Kind<F, B>): Kind<F, A>
flatten open fun <A> Kind<F, Kind<F, A>>.flatten(): Kind<F, A>
followedBy Given two actions, it performs them sequentially. Ignores the result of the first fun <A, B> Kind<F, A>.followedBy(fb: Kind<F, B>): Kind<F, B>
followedByEval open fun <A, B> Kind<F, A>.followedByEval(fb: Eval<Kind<F, B>>): Kind<F, B>
forEffect open fun <A, B> Kind<F, A>.~~forEffect~~(fb: Kind<F, B>): Kind<F, A>
forEffectEval open fun <A, B> Kind<F, A>.~~forEffectEval~~(fb: Eval<Kind<F, B>>): Kind<F, A>
ifM open fun <B> Kind<F, Boolean>.ifM(ifTrue: () -> Kind<F, B>, ifFalse: () -> Kind<F, B>): Kind<F, B>
map Transform the F wrapped value A into B preserving the F structure Kind<F, A> -> Kind<F, B>open fun <A, B> Kind<F, A>.map(f: (A) -> B): Kind<F, B>
mproduct open fun <A, B> Kind<F, A>.mproduct(f: (A) -> Kind<F, B>): Kind<F, Tuple2<A, B>>
productL open fun <A, B> Kind<F, A>.productL(fb: Kind<F, B>): Kind<F, A>
productLEval open fun <A, B> Kind<F, A>.productLEval(fb: Eval<Kind<F, B>>): Kind<F, A>
select open fun <A, B> Kind<F, Either<A, B>>.select(f: Kind<F, (A) -> B>): Kind<F, B>
selectM open fun <A, B> Kind<F, Either<A, B>>.selectM(f: Kind<F, (A) -> B>): Kind<F, B>
tailRecM abstract fun <A, B> tailRecM(a: A, f: (A) -> Kind<F, Either<A, B>>): Kind<F, B>


Bimonad interface Bimonad<F> : Monad<F>, Comonad<F>
MonadContinuation open class MonadContinuation<F, A> : Continuation<Kind<F, A>>, Monad<F>, BindSyntax<F>, MonadSyntax<F>
MonadError interface MonadError<F, E> : ApplicativeError<F, E>, Monad<F>
MonadFilter interface MonadFilter<F> : Monad<F>, FunctorFilter<F>
MonadPlus MonadPlus is a typeclass that extends a Monad by supporting choice and failure. It is equal to Alternative in its api, but provides additional laws for how flatMap and empty interact.interface MonadPlus<F> : Monad<F>, Alternative<F>
MonadSyntax interface MonadSyntax<F> : Monad<F>, BindSyntax<F>

Type Class Hierarchy

Do you like Arrow?

Arrow Org