Example #1
0
 public static StateMaybe <bool, TState> DoWhile <TState>(this
                                                          StateMaybe <bool, TState> @this
                                                          ) where TState : struct
 {
     @this.AssumeInvariant();
     return(DoWhile(@this.RunState));
 }
Example #2
0
 public static Func <TState, StateMaybe <TValue, TState> .StateTuple> Lift <TValue, TState>(this
                                                                                            StateMaybe <TValue, TState> @this
                                                                                            ) where TValue : struct where TState : struct
 {
     Contract.Ensures(Contract.Result <Func <TState, StateMaybe <TValue, TState> .StateTuple> >() != null);
     return(s => @this.RunState(s).Bind(x => StateMaybe <TValue, TState> .Return(x, s)));
 }
Example #3
0
        public static StateMaybe <bool, TState> DoWhile <TState>(this
                                                                 StateMaybe <bool, TState> .Transformer @this
                                                                 ) where TState : struct
        {
            @this.ContractedNotNull("this");

            return(new StateMaybe <bool, TState>(s => {
                StateMaybe <bool, TState> .StateTuple tuple;
                do
                {
                    tuple = @this(s); s = tuple.State;
                } while (tuple.Value.Extract(false));
                return tuple;
            }));
        }