arrow-mtl-data / arrow.mtl / AccumT

AccumT

@higherkind data class AccumT<S, F, A>

AccumT<S, F, A> is a stateful computation within a context F yielding a value of type A. AccumT provides append-only accumulation during the computation. For more general access, use StateT instead.

When flatMapping the resulting state of subcomputations is combined using Monoid<S>

Parameters

F - the context that wraps the stateful computation.

S - the state we are performing computation upon.

A - current value of computation.

accumF - the stateful computation that is wrapped and managed by AccumT

Constructors

<init> AccumT<S, F, A> is a stateful computation within a context F yielding a value of type A. AccumT provides append-only accumulation during the computation. For more general access, use StateT instead.AccumT(accumT: AccumTFun<S, F, A>)

Properties

accumT val accumT: AccumTFun<S, F, A>

Functions

ap fun <B> ap(MS: Monoid<S>, MF: Monad<F>, mf: <ERROR CLASS><S, F, (A) -> B>): AccumT<S, F, B>
evalAccumT Evaluate an accumulation computation with the given initial output history and return the final value, discarding the final output.fun evalAccumT(MF: Monad<F>, s: S): Kind<F, A>
execAccumT Extract the output from an accumulation computation.fun execAccumT(MF: Monad<F>, s: S): Kind<F, S>
flatMap fun <B> flatMap(MS: Monoid<S>, MF: Monad<F>, fa: (A) -> <ERROR CLASS><S, F, B>): AccumT<S, F, B>
map fun <B> map(MF: Functor<F>, fab: (A) -> B): AccumT<S, F, B>
mapAccumT Map both the return value and output of a computation using the given function.fun <G, B> mapAccumT(fas: (Kind<F, Tuple2<S, A>>) -> Kind<G, Tuple2<S, B>>): AccumT<S, G, B>
runAccumT Unwrap an accumulation computation.fun runAccumT(s: S): Kind<F, Tuple2<S, A>>
toStateT Convert an accumulation (append-only) computation into a fully stateful computation.fun toStateT(MF: Monad<F>, MS: Monoid<S>): StateT<F, S, A>

Companion Object Functions

add add w is an action that produces the output w.fun <S, F> add(MF: Monad<F>, s: S): AccumT<S, F, Unit>
invoke operator fun <S, F, A> invoke(accumTFun: AccumTFun<S, F, A>): AccumT<S, F, A>
just fun <S, F, A> just(MS: Monoid<S>, MF: Monad<F>, a: A): AccumT<S, F, A>
liftF fun <F, S, A> liftF(MS: Monoid<S>, AF: Applicative<F>, fa: Kind<F, A>): AccumT<S, F, A>
look look is an action that fetches all the previously accumulated output.fun <S, F> look(MS: Monoid<S>, MF: Monad<F>): AccumT<S, F, S>
looks looks is an action that retrieves a function of the previously accumulated output.fun <S, F, A> looks(MS: Monoid<S>, MF: Monad<F>, fs: (S) -> A): AccumT<S, F, A>
tailRecM fun <S, F, A, B> tailRecM(MF: Monad<F>, a: A, fa: (A) -> Kind<<ERROR CLASS><S, F>, Either<A, B>>): AccumT<S, F, B>

Extension Functions

evalAccum fun <S, A> Accum<S, A>.evalAccum(s: S): A
execAccum fun <S, A> Accum<S, A>.execAccum(s: S): S
flatMap fun <S, A, B> Accum<S, A>.flatMap(MS: Monoid<S>, fa: (A) -> Accum<S, B>): Accum<S, B>
map fun <S, A, B> Accum<S, A>.map(fa: (A) -> B): Accum<S, B>
mapAccum fun <S, A, B> Accum<S, A>.mapAccum(f: (Tuple2<S, A>) -> Tuple2<S, B>): Accum<S, B>
runAccum fun <S, A> Accum<S, A>.runAccum(s: S): Tuple2<S, A>

Do you like Arrow?

Arrow Org
<