public static TState Execute <TEnvironment, TOutput, TState, TValue>(this IRWSMonad <TEnvironment, TOutput, TState, TValue> self, TEnvironment environment, TState state, Action <TValue> onValue)
        {
            RWSResult <TOutput, TState, TValue> selfResult = self.RunRWS(environment, state);

            onValue(selfResult.Value);
            return(selfResult.State);
        }
            public RWSResult <TOutput, TState, TValue> RunRWS(TEnvironment environment, TState state)
            {
                RWSResult <TOutput, TState, TValue> selfResult = _self.RunRWS(environment, state);

                _action(selfResult.Output);
                return(selfResult);
            }
Exemple #3
0
        public static TState Execute <TEnvironment, TOutput, TState, TValue>(this IRWSMonad <TEnvironment, TOutput, TState, TValue> self, TEnvironment environment, TState state, Action <TValue> onValue, Action <TState> onState, Action <IEnumerable <TOutput> > onOutput)
        {
            RWSResult <TOutput, TState, TValue> selfResult = self.Run(environment, state);

            onValue(selfResult.Value);
            onState(selfResult.State);
            onOutput(selfResult.Output);
            return(selfResult.State);
        }
Exemple #4
0
            public RWSResult <TOutput, TState, TValue> Run(TEnvironment environment, TState state)
            {
                RWSResult <TOutput, TState, TValue> result = _self.Run(environment, state);

                if (_selector(result))
                {
                    return(result);
                }
                else
                {
                    return(_elseSource.Run(environment, state));
                }
            }
            public RWSResult <TOutput, TState, TResult> RunRWS(TEnvironment environment, TState state)
            {
                RWSResult <TOutput, TState, TValue> selfResult = _self.RunRWS(environment, state);

                return(_selector(selfResult.Value).RunRWS(environment, selfResult.State ?? state));
            }
Exemple #6
0
 public RWSResult <TOutput, TState, TValue> Run(TEnvironment environment, TState state)
 {
     return(RWSResult.Create(_value, new TOutput[0], state));
 }
 public static IRWSMonad <TEnvironment, TOutput, TState, TValue> Tell <TEnvironment, TOutput, TState, TValue>(TValue value, IEnumerable <TOutput> outputs)
 {
     return(RWS.Create <TEnvironment, TOutput, TState, TValue>((e, s) => RWSResult.Create(value, outputs, s)));
 }
 public static IRWSMonad <TEnvironment, TOutput, TState, TValue> Tell <TEnvironment, TOutput, TState, TValue>(TValue value, TOutput output)
 {
     return(RWS.Create <TEnvironment, TOutput, TState, TValue>((e, s) => RWSResult.Create(value, new TOutput[1] {
         output
     }, s)));
 }
 public RWSResult <TOutput, TState, Unit> Run(TEnvironment environment, TState state)
 {
     return(RWSResult.Create(Unit.Default, new TOutput[1] {
         _output
     }, state));
 }
Exemple #10
0
 public RWSResult <TOutput, TState, TState> Run(TEnvironment environment, TState state)
 {
     return(RWSResult.Create(state, new TOutput[0], _selector(state)));
 }
Exemple #11
0
 public RWSResult <TOutput, TState, TEnvironment> RunRWS(TEnvironment environment, TState state)
 {
     return(RWSResult.Create(_selector(environment), new TOutput[0], state));
 }