Esempio n. 1
0
        /// <summary>
        /// SelectMany
        /// </summary>
        public static EitherStrict <L, VR> SelectMany <L, TR, UR, VR>(
            this EitherStrict <L, TR> self,
            Func <TR, EitherStrict <L, UR> > selector,
            Func <TR, UR, VR> projector)
        {
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }
            if (projector == null)
            {
                throw new ArgumentNullException("projector");
            }

            if (self.IsLeft)
            {
                return(EitherStrict.Left <L, VR>(self.Left));
            }

            var res = selector(self.Right);

            if (res.IsLeft)
            {
                return(EitherStrict.Left <L, VR>(res.Left));
            }

            return(EitherStrict.Right <L, VR>(projector(self.Right, res.Right)));
        }
Esempio n. 2
0
        /// <summary>
        /// Select
        /// </summary>
        public static EitherStrict <L, UR> Select <L, TR, UR>(
            this EitherStrict <L, TR> self,
            Func <TR, UR> selector)
        {
            if (selector == null)
            {
                throw new ArgumentNullException("selector");
            }

            if (self.IsLeft)
            {
                return(EitherStrict.Left <L, UR>(self.Left));
            }

            return(EitherStrict.Right <L, UR>(selector(self.Right)));
        }