// M<T> -> Func<T, TResult> -> M<TResult> public static State <TState, TResult> Select <TState, T, TResult>( this State <TState, T> self, Func <T, TResult> operation) { Debug.Assert(self != null); Debug.Assert(operation != null); return(state => { var stateResult = self(state); return StateResult.Create( stateResult.State, operation(stateResult.Value)); }); }
public static State <TState, Unit> Modify <TState>(Func <TState, TState> operation) { Debug.Assert(operation != null); return(state => StateResult.Create(operation(state), Unit.Value)); }
public static State <TState, TState> Get <TState>() { return(state => StateResult.Create(state, state)); }
public static State <TState, Unit> Put <TState>(TState state) { return(_ => StateResult.Create(state, Unit.Value)); }
public static State <TState, T> ToState <TState, T>(this T value) { return(state => StateResult.Create(state, value)); }