arrow-core-data / arrow.typeclasses / Alternative

Alternative

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

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

Functions

alt Combines two computations. Infix alias over orElse.open infix fun <A> Kind<F, A>.alt(b: Kind<F, A>): Kind<F, A>
combineK Combine two F values.open 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 failure.open 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 succeed.open fun <A> Kind<F, A>.many(): Kind<F, SequenceK<A>>
optional Wraps the result in an optional. This never fails.open 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 once.open fun <A> Kind<F, A>.some(): Kind<F, SequenceK<A>>

Inheritors

MonadCombine interface MonadCombine<F> : MonadFilter<F>, Alternative<F>

Type Class Hierarchy

Do you like Arrow?

Arrow Org
<