// Exceptional public static Exceptional <IEnumerable <R> > Traverse <T, R>(this IEnumerable <T> list, Func <T, Exceptional <R> > func) => list.Aggregate( seed: Exceptional.Of(Enumerable.Empty <R>()), // Exceptional<R> -> T -> Exceptional<[R]> func: (optRs, t) => from rs in optRs from r in func(t) select rs.Append(r));
Exception ExceptionOrDefault(Exceptional <T> ex) => ex.Match(exc => exc, _ => default(Exception));
T ValueOrDefault(Exceptional <T> ex) => ex.Match(exc => default(T), t => t);
bool IsSuccess(Exceptional <T> ex) => ex.Match(_ => false, _ => true);
public static Validation<Exceptional<R>> Traverse<T, R> (this Exceptional<T> tr, Func<T, Validation<R>> f) => tr.Match( Exception: e => Valid((Exceptional<R>)e), Success: t => from r in f(t) select Exceptional(r));