public ValueOrErrorMonad <R> Select <R>(Func <T, R> func) { Func <T, ValueOrErrorMonad <R> > tryCatchFunction = x => { try { return(ValueOrErrorMonad <R> .FromValue(func(x))); } catch (Exception e) { return(ValueOrErrorMonad <R> .FromError(e.Message)); } }; return(Bind(tryCatchFunction)); }
public ValueOrErrorMonad <R> Bind <R>(Func <T, ValueOrErrorMonad <R> > function) { return(!IsError?function(Value) : ValueOrErrorMonad <R> .FromError(Error)); }