Exemplo n.º 1
0
        // 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));
            });
        }
Exemplo n.º 2
0
        public static State <TState, Unit> Modify <TState>(Func <TState, TState> operation)
        {
            Debug.Assert(operation != null);

            return(state => StateResult.Create(operation(state), Unit.Value));
        }
Exemplo n.º 3
0
 public static State <TState, TState> Get <TState>()
 {
     return(state => StateResult.Create(state, state));
 }
Exemplo n.º 4
0
 public static State <TState, Unit> Put <TState>(TState state)
 {
     return(_ => StateResult.Create(state, Unit.Value));
 }
Exemplo n.º 5
0
 public static State <TState, T> ToState <TState, T>(this T value)
 {
     return(state => StateResult.Create(state, value));
 }