Esempio 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));
            });
        }
Esempio 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));
        }
Esempio n. 3
0
 public static State <TState, TState> Get <TState>()
 {
     return(state => StateResult.Create(state, state));
 }
Esempio n. 4
0
 public static State <TState, Unit> Put <TState>(TState state)
 {
     return(_ => StateResult.Create(state, Unit.Value));
 }
Esempio n. 5
0
 public static State <TState, T> ToState <TState, T>(this T value)
 {
     return(state => StateResult.Create(state, value));
 }