示例#1
0
        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));
        }
示例#2
0
 public ValueOrErrorMonad <R> Bind <R>(Func <T, ValueOrErrorMonad <R> > function)
 {
     return(!IsError?function(Value) : ValueOrErrorMonad <R> .FromError(Error));
 }