Package fj.data
Class State<S,A>
- java.lang.Object
-
- fj.data.State<S,A>
-
public final class State<S,A> extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <B> State<S,B>bind(F<A,State<S,B>> f)Bind the given function across this state.static <S,A>
State<S,A>constant(A a)private static <S> P2<S,S>dup(S s)Aeval(S s)Sexec(S s)static <S,A,B>
State<S,B>flatMap(State<S,A> ts, F<A,State<S,B>> f)<B> State<S,B>flatMap(F<A,State<S,B>> f)Bind the given function across this state.State<S,S>gets()static <S,A>
State<S,A>gets(F<S,A> f)static <S> State<S,S>init()<B> State<S,B>map(F<A,B> f)<B> State<S,B>mapState(F<P2<S,A>,P2<S,B>> f)static <S> State<S,Unit>modify(F<S,S> f)static <S> State<S,Unit>put(S s)P2<S,A>run(S s)static <S,A>
State<S,List<A>>sequence(List<State<S,A>> list)Evaluate each action in the sequence from left to right, and collect the results.private static <S,A>
State<S,A>suspended(F<S,Trampoline<P2<S,A>>> runF)static <S,A,B>
State<S,List<B>>traverse(List<A> list, F<A,State<S,B>> f)Map each element of a structure to an action, evaluate these actions from left to right and collect the results.static <S,A>
State<S,A>unit(F<S,P2<S,A>> runF)static <S> State<S,S>units(F<S,S> f)State<S,A>withs(F<S,S> f)
-
-
-
Method Detail
-
init
public static <S> State<S,S> init()
-
dup
private static <S> P2<S,S> dup(S s)
-
constant
public static <S,A> State<S,A> constant(A a)
-
sequence
public static <S,A> State<S,List<A>> sequence(List<State<S,A>> list)
Evaluate each action in the sequence from left to right, and collect the results.
-
traverse
public static <S,A,B> State<S,List<B>> traverse(List<A> list, F<A,State<S,B>> f)
Map each element of a structure to an action, evaluate these actions from left to right and collect the results.
-
suspended
private static <S,A> State<S,A> suspended(F<S,Trampoline<P2<S,A>>> runF)
-
bind
public <B> State<S,B> bind(F<A,State<S,B>> f)
Bind the given function across this state.- Type Parameters:
B- the type of the output value- Parameters:
f- the given function- Returns:
- the state
-
-