arrow-mtl-data / arrow.mtl / StateT

StateT

@higherkind class StateT<S, F, A>

StateT<S, F, A> is a stateful computation within a context F yielding a value of type A. i.e. StateT<S, EitherPartialOf, A> = Either<E, State<S, A>>

Parameters

F - the context that wraps the stateful computation.

S - the state we are performing computation upon.

A - current value of computation.

runF - the stateful computation that is wrapped and managed by StateT

Properties

runF the stateful computation that is wrapped and managed by StateTval runF: StateTFun<S, F, A>

Functions

ap Apply a function (S) -> B that operates within the StateT context.fun <B> ap(MF: Monad<F>, ff: <ERROR CLASS><S, F, (A) -> B>): StateT<S, F, B>
combineK Combine two StateT objects using an instance of SemigroupK for F.fun combineK(SF: SemigroupK<F>, y: <ERROR CLASS><S, F, A>): StateT<S, F, A>
flatMap Map the value A to another StateT object for the same state S and context F and flatten the structure.fun <B> flatMap(MF: Monad<F>, fas: (A) -> <ERROR CLASS><S, F, B>): StateT<S, F, B>
flatMapF Map the value A to a arbitrary type B that is within the context of F.fun <B> flatMapF(MF: Monad<F>, faf: (A) -> Kind<F, B>): StateT<S, F, B>
map Map current value A given a function f.fun <B> map(FF: Functor<F>, f: (A) -> B): StateT<S, F, B>
runA Run the stateful computation within the context F and get the value A.fun runA(MF: Monad<F>, s: S): Kind<F, A>
runS Run the stateful computation within the context F and get the state S.fun runS(MF: Monad<F>, s: S): Kind<F, S>
transform Transform the product of state S and value A to an another product of state S and an arbitrary type B.fun <B> transform(FF: Functor<F>, f: (Tuple2<S, A>) -> Tuple2<S, B>): StateT<S, F, B>

Companion Object Functions

get Return input without modifying it.fun <S, F> get(AF: Applicative<F>): StateT<S, F, S>
inspect Inspect a value of the state S with f (S) -> T without modifying the state.fun <S, F, T> inspect(AF: Applicative<F>, f: (S) -> T): StateT<S, F, T>
invoke operator fun <S, F, A> invoke(f: (S) -> Kind<F, Tuple2<S, A>>): StateT<S, F, A>
just fun <S, F, T> just(AF: Applicative<F>, t: T): StateT<S, F, T>
liftF Lift a value of type Kind<F, A> into StateT<S, F, A>.fun <S, F, A> liftF(AF: Applicative<F>, fa: Kind<F, A>): StateT<S, F, A>
modify Modify the state with f (S) -> S and return Unit.fun <S, F> modify(AF: Applicative<F>, f: (S) -> S): StateT<S, F, Unit>
modifyF Modify the state with an Applicative function f (S) -> Kind<F, S> and return Unit.fun <S, F> modifyF(AF: Applicative<F>, f: (S) -> Kind<F, S>): StateT<S, F, Unit>
set Set the state to a value s and return Unit.fun <S, F> set(AF: Applicative<F>, s: S): StateT<S, F, Unit>
setF Set the state to a value s of type Kind<F, S> and return Unit.fun <S, F> setF(AF: Applicative<F>, s: Kind<F, S>): StateT<S, F, Unit>
tailRecM Tail recursive function that keeps calling f until arrow.Either.Right is returned.fun <S, F, A, B> tailRecM(MF: Monad<F>, a: A, f: (A) -> <ERROR CLASS><S, F, Either<A, B>>): StateT<S, F, B>

Extension Functions

flatMap fun <S, A, B> State<S, A>.flatMap(f: (A) -> State<S, B>): State<S, B>
map fun <S, T, P1, R> State<S, T>.map(sx: State<S, P1>, f: (T, P1) -> R): State<S, R>
fun <S, T, R> State<S, T>.map(f: (T) -> R): State<S, R>
run fun <S, A> State<S, A>.run(initial: S): Tuple2<S, A>
runA Alias for StateT.runA StateT<S, ForId, A>fun <S, A> StateT<S, ForId, A>.runA(initial: S): A
runS Alias for StateT.runS StateT<S, ForId, A>fun <S, A> StateT<S, ForId, A>.runS(initial: S): S

Do you like Arrow?

Arrow Org
<