public static WriterResult <W, A> Tell <W, A>(A a, IEnumerable <W> ws) { if (ws == null) { throw new ArgumentNullException("ws"); } return(WriterResult.Create <W, A>(a, ws)); }
/// <summary> /// Select /// </summary> public static Writer <W, U> Select <W, T, U>(this Writer <W, T> self, Func <T, U> select) { if (select == null) { throw new ArgumentNullException("select"); } return(() => { var resT = self(); var resU = select(resT.Value); return WriterResult.Create <W, U>(resU, resT.Output); }); }
/// <summary> /// Select Many /// </summary> public static Writer <W, V> SelectMany <W, T, U, V>( this Writer <W, T> self, Func <T, Writer <W, U> > bind, Func <T, U, V> project ) { if (bind == null) { throw new ArgumentNullException("bind"); } if (project == null) { throw new ArgumentNullException("project"); } return(() => { var resT = self(); var resU = bind(resT.Value).Invoke(); var resV = project(resT.Value, resU.Value); return WriterResult.Create <W, V>(resV, resT.Output.Concat(resU.Output)); }); }
public static Writer <W, Unit> Tell <W>(W value) { return(() => WriterResult.Create <W, Unit>(Unit.Default, new W[1] { value })); }
public static WriterResult <W, A> Tell <W, A>(A a, W w) { return(WriterResult.Create <W, A>(a, new W[1] { w })); }
public static Writer <W, A> Return <W, A>(A a) { return(() => WriterResult.Create <W, A>(a, new W[0])); }