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)); }
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)); }
// Functor public static IEither <L, R1> Select <L, R, R1>( this IEither <L, R> source, Func <R, R1> selector) { return(source.SelectRight(selector)); }
public void SelectRightObeysFirstFunctorLaw(IEither <string, int> e) { Assert.Equal(e, e.SelectRight(Id)); }