Esempio n. 1
0
 public static Fin <B> apply <A, B>(Fin <Func <A, B> > fab, Fin <A> fa)
 {
     if (fab.IsFail)
     {
         return(Fin <B> .Fail(fab.Error));
     }
     if (fa.IsFail)
     {
         return(Fin <B> .Fail(fa.Error));
     }
     return(fab.Value(fa.Value));
 }
Esempio n. 2
0
 public static Fin <Func <B, C> > apply <A, B, C>(Fin <Func <A, Func <B, C> > > fabc, Fin <A> fa)
 {
     if (fabc.IsFail)
     {
         return(Fin <Func <B, C> > .Fail(fabc.Error));
     }
     if (fa.IsFail)
     {
         return(Fin <Func <B, C> > .Fail(fa.Error));
     }
     return(fabc.Value(fa.Value));
 }
Esempio n. 3
0
 public static Fin <C> apply <A, B, C>(Fin <Func <A, B, C> > fabc, Fin <A> fa, Fin <B> fb)
 {
     if (fabc.IsFail)
     {
         return(Fin <C> .Fail(fabc.Error));
     }
     if (fa.IsFail)
     {
         return(Fin <C> .Fail(fa.Error));
     }
     if (fb.IsFail)
     {
         return(Fin <C> .Fail(fb.Error));
     }
     return(fabc.Value(fa.Value, fb.Value));
 }
Esempio n. 4
0
 public static Try <Fin <B> > Traverse <A, B>(this Fin <Try <A> > ma, Func <A, B> f) => () =>
 {
     if (ma.IsFail)
     {
         return(new Result <Fin <B> >(ma.Cast <B>()));
     }
     var mr = ma.Value();
     if (mr.IsBottom)
     {
         return(new Result <Fin <B> >(BottomException.Default));
     }
     if (mr.IsFaulted)
     {
         return(new Result <Fin <B> >(mr.Exception));
     }
     return(new Result <Fin <B> >(Fin <B> .Succ(f(mr.Value))));
 };