Beispiel #1
0
 public static Writer <Out, Reader <E, V> > SelectMany <Out, E, T, U, V>(
     this Writer <Out, T> self,
     Func <T, Reader <E, 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();
         if (resT.IsBottom)
         {
             return WriterResult.Bottom <Out, Reader <E, V> >(resT.Output);
         }
         return WriterResult.Return <Out, Reader <E, V> >(env =>
         {
             var resU = bind(resT.Value)(env);
             if (resU.IsBottom)
             {
                 return ReaderResult.Bottom <V>();
             }
             return ReaderResult.Return(project(resT.Value, resU.Value));
         }, resT.Output);
     });
 }
Beispiel #2
0
 private static ReaderResult <T> Bottom <T>() =>
 ReaderResult.Bottom <T>();