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()); }
public Try <U> Select <U>(Func <T, U> selector) => Try.Create(() => selector(Value));
public Try <T> Recover(Func <Exception, Try <T> > recover) => Try.Create(() => recover(_exception)).Flatten();
public Try <T> Recover <TException>(Func <TException, Maybe <T> > recover) { return(Try.Create(() => _exception.MaybeAs <TException>().Bind(recover).ToTry(() => _exception)).Flatten()); }
public Try <T> Recover(Func <Exception, T> recover) => Try.Create(() => recover(_exception));
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))); }