Beispiel #1
0
        //public static Writer<W, B> Bind<W, A, B>(Writer<W, A> m, WriterFunc<W, A, B> f)
        //{
        //    return Writer(() =>
        //    {
        //        var resultA = m.Func();
        //        var writerB = f(resultA.Value);
        //        var resultB = writerB.Func();
        //        return WriterResult.New(resultB.Value, resultA.Output.Concat(resultB.Output));
        //    });
        //}

        public static Writer <W, B> Bind <W, A, B>(Writer <W, A> m, Func <A, Writer <W, B> > f)
        {
            return(Writer(() =>
            {
                var resultA = m.Func();
                var writerB = f(resultA.Value);
                var resultB = writerB.Func();
                return WriterResult.New(resultB.Value, resultA.Output.Concat(resultB.Output));
            }));
        }
Beispiel #2
0
 public static Writer <W, A> Unit <W, A>(A a)
 => Writer(() => WriterResult.New(a, Enumerable.Empty <W>()));
Beispiel #3
0
 public static Writer <W, Common.Void> Tell <W>(W w)
 => Writer <W, Common.Void>(() => WriterResult.New(Common.Void.Default, new[] { w }));