public void SecondFunctorLawHoldsForMapRight(IEitherValueType <string, int> e) { char f(bool b) => b ? 'T' : 'F'; bool g(int i) => i % 2 == 0; Assert.AreEqual(e.MapRight(x => f(g(x))), e.MapRight(g).MapRight(f)); }
public void SecondFunctorLawHoldsForMapLeft(IEitherValueType <string, int> e) { bool f(int x) => x % 2 == 0; int g(string s) => s.Length; Assert.AreEqual(e.MapLeft(x => f(g(x))), e.MapLeft(g).MapLeft(f)); }
public void ConsistencyLawHolds(IEitherValueType <string, int> e) { bool f(string s) => string.IsNullOrWhiteSpace(s); DateTime g(int i) => new DateTime(i); Assert.AreEqual(e.Map(f, g), e.MapRight(g).MapLeft(f)); Assert.AreEqual( e.MapLeft(f).MapRight(g), e.MapRight(g).MapLeft(f)); }
public void MapCompositionLawHolds(IEitherValueType <string, int> e) { bool f(int x) => x % 2 == 0; int g(string s) => s.Length; char h(bool b) => b ? 'T' : 'F'; bool i(int x) => x % 2 == 0; Assert.AreEqual( e.Map(x => f(g(x)), y => h(i(y))), e.Map(g, i).Map(f, h)); }
public void MapOnExtensionMethodObeysFirstFunctorLaw(IEitherValueType <string, int> e) { e.Should().Be(e.Map(l => Identity(l), r => Identity(r))); }
public void MapLeftObeysFirstFunctorLaw(IEitherValueType <string, int> e) { e.Should().Be(e.MapLeft(l => Identity(l))); }