Beispiel #1
0
        public void SecondFunctorLawHoldsForSelectRight(IEither <string, int> e)
        {
            char f(bool b) => b ? 'T' : 'F';
            bool g(int i) => i % 2 == 0;

            Assert.Equal(
                e.SelectRight(x => f(g(x))),
                e.SelectRight(g).SelectRight(f));
        }
Beispiel #2
0
        public void ConsistencyLawHolds(IEither <string, int> e)
        {
            bool f(string s) => string.IsNullOrWhiteSpace(s);
            DateTime g(int i) => new DateTime(i);

            Assert.Equal(e.SelectBoth(f, g), e.SelectRight(g).SelectLeft(f));
            Assert.Equal(
                e.SelectLeft(f).SelectRight(g),
                e.SelectRight(g).SelectLeft(f));
        }
Beispiel #3
0
 // Functor
 public static IEither <L, R1> Select <L, R, R1>(
     this IEither <L, R> source,
     Func <R, R1> selector)
 {
     return(source.SelectRight(selector));
 }
Beispiel #4
0
 public void SelectRightObeysFirstFunctorLaw(IEither <string, int> e)
 {
     Assert.Equal(e, e.SelectRight(Id));
 }