arrow-core-data / arrow.typeclasses / Alternative


interface Alternative<F> : Applicative<F>, MonoidK<F>

The Alternative type class is for Applicative functors which also have a monoid structure.


alt Combines two computations. Infix alias over infix fun <A> Kind<F, A>.alt(b: Kind<F, A>): Kind<F, A>
combineK Combine two F fun <A> Kind<F, A>.combineK(y: Kind<F, A>): Kind<F, A>
guard open fun guard(b: Boolean): Kind<F, Unit>
lazyOrElse Lazy or else, useful when traversing a structure with asum which short circuits on success. In general this should be implemented for every Alternative that models success and fun <A> Kind<F, A>.lazyOrElse(b: () -> Kind<F, A>): Kind<F, A>
many Repeats the computation until it fails. Does not requires it to fun <A> Kind<F, A>.many(): Kind<F, SequenceK<A>>
optional Wraps the result in an optional. This never fun <A> Kind<F, A>.optional(): Kind<F, Option<A>>
orElse Combines two computations.abstract fun <A> Kind<F, A>.orElse(b: Kind<F, A>): Kind<F, A>
some Repeats the computation until it fails. Requires it to succeed at least fun <A> Kind<F, A>.some(): Kind<F, SequenceK<A>>


MonadCombine interface MonadCombine<F> : MonadFilter<F>, Alternative<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>

Type Class Hierarchy

Do you like Arrow?

Arrow Org