Example #1
0
 internal static RWS <MonoidW, R, W, S, List <B> > TraverseFast <MonoidW, R, W, S, A, B>(this IEnumerable <RWS <MonoidW, R, W, S, A> > ma, Func <A, B> f) where MonoidW : struct, Monoid <W> => (env, state) =>
 {
     var values = new List <B>();
     var output = default(MonoidW).Empty();
     foreach (var item in ma)
     {
         var res = item(env, state);
         if (res.IsFaulted)
         {
             return(RWSResult <MonoidW, R, W, S, List <B> > .New(state, res.Error));
         }
         values.Add(f(res.Value));
         state  = res.State;
         output = default(MonoidW).Append(output, res.Output);
     }
     return(RWSResult <MonoidW, R, W, S, List <B> > .New(output, state, values));
 };
Example #2
0
 public static RWS <MonoidW, R, W, S, A> RWS <MonoidW, R, W, S, A>(W output, A value) where MonoidW : struct, Monoid <W> => (_, state) =>
 RWSResult <MonoidW, R, W, S, A> .New(output, state, value);
Example #3
0
 public static RWS <MonoidW, R, W, S, A> RWS <MonoidW, R, W, S, A>(S state, A value) where MonoidW : struct, Monoid <W> => (_, __) =>
 RWSResult <MonoidW, R, W, S, A> .New(state, value);