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))); }
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)); }); }
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); }); }
public static State <S, Unit> Put <S>(S state) { return(_ => StateResult.Create <S, Unit>(state, Unit.Default)); }
public static State <S, S> Get <S>() { return((S state) => StateResult.Create <S, S>(state, state)); }