示例#1
0
 public static State <S, S> Get <S>(Func <S, S> f)
 {
     if (f == null)
     {
         throw new ArgumentNullException("f");
     }
     return((S state) => StateResult.Create <S, S>(state, f(state)));
 }
示例#2
0
 public static State <S, U> Select <S, T, U>(this State <S, T> self, Func <T, U> map)
 {
     if (map == null)
     {
         throw new ArgumentNullException("map");
     }
     return((S state) =>
     {
         var resT = self(state);
         return StateResult.Create <S, U>(resT.State, map(resT.Value));
     });
 }
示例#3
0
 public static State <S, A> With <S, A>(this State <S, A> self, Func <S, S> f)
 {
     if (f == null)
     {
         throw new ArgumentNullException("f");
     }
     return((S state) =>
     {
         var res = self(state);
         return StateResult.Create <S, A>(f(res.State), res.Value);
     });
 }
示例#4
0
 public static State <S, Unit> Put <S>(S state)
 {
     return(_ => StateResult.Create <S, Unit>(state, Unit.Default));
 }
示例#5
0
 public static State <S, S> Get <S>()
 {
     return((S state) => StateResult.Create <S, S>(state, state));
 }