Пример #1
0
 /// <summary>
 /// Pattern matching method for a branching expression
 /// NOTE: This throws an InvalidOperationException if the object is in the
 /// Left state
 /// </summary>
 /// <param name="right">Action to perform if the monad is in the Right state</param>
 /// <returns>T</returns>
 public static Func <T> MatchRight <R, L, T>(this Either <L, R> m, Func <R, T> right)
 {
     if (right == null)
     {
         throw new ArgumentNullException("right");
     }
     return(() =>
     {
         return right(m.Right());
     });
 }
Пример #2
0
        /// <summary>
        /// Pattern matching method for a branching expression
        /// NOTE: This throws an InvalidOperationException if the object is in the
        /// Left state
        /// </summary>
        /// <param name="right">Action to perform if the monad is in the Right state</param>
        /// <returns>Unit</returns>
        public static Func <Unit> MatchRight <L, R>(this Either <L, R> m, Action <R> right)
        {
            if (right == null)
            {
                throw new ArgumentNullException("right");
            }

            return(() =>
            {
                right(m.Right());
                return Unit.Default;
            });
        }