Example #1
0
 public Try <T> Where(Func <T, bool> filter)
 {
     return(Try.Create <Try <T> >(() =>
     {
         if (filter(Value))
         {
             return this;
         }
         return new Failure <T>(new ArgumentOutOfRangeException($"Predicate does not hold for {Value}"));
     }
                                  ).Flatten());
 }
Example #2
0
 public Try <U> Select <U>(Func <T, U> selector) => Try.Create(() => selector(Value));
Example #3
0
 public Try <T> Recover(Func <Exception, Try <T> > recover) => Try.Create(() => recover(_exception)).Flatten();
Example #4
0
 public Try <T> Recover <TException>(Func <TException, Maybe <T> > recover)
 {
     return(Try.Create(() => _exception.MaybeAs <TException>().Bind(recover).ToTry(() => _exception)).Flatten());
 }
Example #5
0
 public Try <T> Recover(Func <Exception, T> recover) => Try.Create(() => recover(_exception));
Example #6
0
 public Try <T> OrElse(Func <Try <T> > @default) => Try.Create(@default).Flatten();
 public Try <U> Select <U>(Func <T, U> selector)
 {
     return(Try.Create(() => selector(_value)));
 }
 public Try <T> Recover(Func <Exception, Try <T> > recover)
 {
     return(Try.Create(() => recover(Exception)).SelectMany(x => x));
 }
 public Try <T> Recover(Func <Exception, T> recover)
 {
     return(Try.Create(() => recover(Exception)));
 }