public static void LastSemigroupTest() { var m = Semigroup.Last <int>(); Assert.Equal(5, m.Op(99, 5)); Assert.Equal(99, m.Op(5, 99)); }
public void Test01() { var semigroup = Semigroup.make <int>().Require(); var values = seq(0, 1, 2, 3, 4, 5); var sumA = Seq.combine(semigroup.combine, values); var sumB = add(add(add(add(1, 2), 3), 4), 5); claim.equal(sumB, sumA); }
public static void IntLiftInfinityTest() { var intPlus = new Semigroup <int>((x, y) => x + y); var intPlusInf = intPlus.LiftSemigroupWithInfinity(); var r = intPlusInf.Op(Maybe.Just(3), Maybe.Just(8)); Assert.True(r.HasValue); Assert.Equal(11, r.Value()); r = intPlusInf.Op(Maybe.Nothing <int>(), Maybe.Just(8)); Assert.False(r.HasValue); r = intPlusInf.Op(Maybe.Just(3), Maybe.Nothing <int>()); Assert.False(r.HasValue); r = intPlusInf.Op(Maybe.Nothing <int>(), Maybe.Nothing <int>()); Assert.False(r.HasValue); }
public static Maybe <A> SemiOp <A>(this Maybe <A> maybe, Maybe <A> other) { return(Semigroup.Maybe <A>().Op(maybe, other)); }
public static NonEmptyLazyList <A> SemiOp <A>(this NonEmptyLazyList <A> nel, NonEmptyLazyList <A> other) { return(Semigroup.NonEmptyLazyList <A>().Op(nel, other)); }
public static Either <X, A> SemiOp <X, A>(this Either <X, A> either, Either <X, A> other) { return(Semigroup.Either <X, A>().Op(either, other)); }