Beispiel #1
0
        public static void LastSemigroupTest()
        {
            var m = Semigroup.Last <int>();

            Assert.Equal(5, m.Op(99, 5));
            Assert.Equal(99, m.Op(5, 99));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public static Maybe <A> SemiOp <A>(this Maybe <A> maybe, Maybe <A> other)
 {
     return(Semigroup.Maybe <A>().Op(maybe, other));
 }
Beispiel #5
0
 public static NonEmptyLazyList <A> SemiOp <A>(this NonEmptyLazyList <A> nel, NonEmptyLazyList <A> other)
 {
     return(Semigroup.NonEmptyLazyList <A>().Op(nel, other));
 }
Beispiel #6
0
 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));
 }