示例#1
0
 public static Fin <Func <B, C> > Apply <A, B, C>(this Func <A, Func <B, C> > fabc, Fin <A> fa)
 {
     if (fa.IsFail)
     {
         return(Fin <Func <B, C> > .Fail(fa.Error));
     }
     return(fabc(fa.Value));
 }
示例#2
0
 public static Fin <B> Apply <A, B>(this 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));
 }
示例#3
0
 public static Fin <C> Apply <A, B, C>(this Func <A, B, C> fabc, Fin <A> fa, Fin <B> fb)
 {
     if (fa.IsFail)
     {
         return(Fin <C> .Fail(fa.Error));
     }
     if (fb.IsFail)
     {
         return(Fin <C> .Fail(fb.Error));
     }
     return(fabc(fa.Value, fb.Value));
 }
示例#4
0
 public static Eff <A> ToEff <A>(this TryOption <A> ma, Func <A> None) =>
 Prelude.EffMaybe(() =>
                  ma.Match(Some: Fin <A> .Succ,
                           None: () => Fin <A> .Succ(None()),
                           Fail: e => Fin <A> .Fail(e)));
示例#5
0
 public static Eff <A> ToEff <A>(this TryOption <A> ma) =>
 Prelude.EffMaybe(() =>
                  ma.Match(Some: Fin <A> .Succ,
                           None: () => Fin <A> .Fail(Error.New("None")),
                           Fail: e => Fin <A> .Fail(e)));
 public static Eff <A> ToEff <A>(this Try <A> ma) =>
 Prelude.EffMaybe(() =>
                  ma.Match(Succ: Fin <A> .Succ,
                           Fail: e => Fin <A> .Fail(e)));