diff --git a/algebra-core/src/main/scala/algebra/lattice/Bool.scala b/algebra-core/src/main/scala/algebra/lattice/Bool.scala index 0899e32787a..c5b5f3b1942 100644 --- a/algebra-core/src/main/scala/algebra/lattice/Bool.scala +++ b/algebra-core/src/main/scala/algebra/lattice/Bool.scala @@ -43,7 +43,7 @@ trait Bool[@sp(Int, Long) A] extends Any with Heyting[A] with GenBool[A] { self * Note that the ring returned by this method is not an extension of * the `Rig` returned from `BoundedDistributiveLattice.asCommutativeRig`. */ - override def asBoolRing: BoolRing[A] = new BoolRingFromBool(self) + override private[algebra] def asBoolRing: BoolRing[A] = new BoolRingFromBool(self) } class DualBool[@sp(Int, Long) A](orig: Bool[A]) extends Bool[A] { @@ -62,7 +62,7 @@ class DualBool[@sp(Int, Long) A](orig: Bool[A]) extends Bool[A] { override def dual: Bool[A] = orig } -private[lattice] class BoolRingFromBool[A](orig: Bool[A]) extends BoolRngFromGenBool(orig) with BoolRing[A] { +class BoolRingFromBool[A](orig: Bool[A]) extends BoolRngFromGenBool(orig) with BoolRing[A] { def one: A = orig.one } @@ -78,7 +78,7 @@ class BoolFromBoolRing[A](orig: BoolRing[A]) extends GenBoolFromBoolRng(orig) wi def one: A = orig.one def complement(a: A): A = orig.plus(orig.one, a) override def without(a: A, b: A): A = super[GenBoolFromBoolRng].without(a, b) - override def asBoolRing: BoolRing[A] = orig + override private[algebra] def asBoolRing: BoolRing[A] = orig override def meet(a: A, b: A): A = super[GenBoolFromBoolRng].meet(a, b) override def join(a: A, b: A): A = super[GenBoolFromBoolRng].join(a, b) diff --git a/algebra-core/src/main/scala/algebra/lattice/BoundedDistributiveLattice.scala b/algebra-core/src/main/scala/algebra/lattice/BoundedDistributiveLattice.scala index ea77f8b7ddb..6d3838bfb9c 100644 --- a/algebra-core/src/main/scala/algebra/lattice/BoundedDistributiveLattice.scala +++ b/algebra-core/src/main/scala/algebra/lattice/BoundedDistributiveLattice.scala @@ -16,7 +16,7 @@ trait BoundedDistributiveLattice[@sp(Int, Long, Float, Double) A] * Return a CommutativeRig using join and meet. Note this must obey the commutative rig laws since * meet(a, one) = a, and meet and join are associative, commutative and distributive. */ - def asCommutativeRig: CommutativeRig[A] = + private[algebra] def asCommutativeRig: CommutativeRig[A] = new CommutativeRig[A] { def zero: A = self.zero def one: A = self.one diff --git a/algebra-core/src/main/scala/algebra/lattice/GenBool.scala b/algebra-core/src/main/scala/algebra/lattice/GenBool.scala index fc982ba1d9b..f8299fac92e 100644 --- a/algebra-core/src/main/scala/algebra/lattice/GenBool.scala +++ b/algebra-core/src/main/scala/algebra/lattice/GenBool.scala @@ -34,7 +34,7 @@ trait GenBool[@sp(Int, Long) A] extends Any with DistributiveLattice[A] with Bou * Every generalized Boolean algebra is also a `BoolRng`, with * multiplication defined as `and` and addition defined as `xor`. */ - def asBoolRing: BoolRng[A] = new BoolRngFromGenBool(self) + private[algebra] def asBoolRing: BoolRng[A] = new BoolRngFromGenBool(self) } /** @@ -54,10 +54,10 @@ class GenBoolFromBoolRng[A](orig: BoolRng[A]) extends GenBool[A] { def and(a: A, b: A): A = orig.times(a, b) def or(a: A, b: A): A = orig.plus(orig.plus(a, b), orig.times(a, b)) def without(a: A, b: A): A = orig.plus(a, orig.times(a, b)) - override def asBoolRing: BoolRng[A] = orig + override private[algebra] def asBoolRing: BoolRng[A] = orig } -private[lattice] class BoolRngFromGenBool[@sp(Int, Long) A](orig: GenBool[A]) extends BoolRng[A] { +class BoolRngFromGenBool[@sp(Int, Long) A](orig: GenBool[A]) extends BoolRng[A] { def zero: A = orig.zero def plus(x: A, y: A): A = orig.xor(x, y) def times(x: A, y: A): A = orig.and(x, y) diff --git a/algebra-laws/shared/src/test/scala/algebra/laws/LawTests.scala b/algebra-laws/shared/src/test/scala/algebra/laws/LawTests.scala index 1c33f7810c0..0e35b30c5d5 100644 --- a/algebra-laws/shared/src/test/scala/algebra/laws/LawTests.scala +++ b/algebra-laws/shared/src/test/scala/algebra/laws/LawTests.scala @@ -60,7 +60,7 @@ class LawTests extends munit.DisciplineSuite { checkAll("Boolean", RingLaws[Boolean].boolRing(booleanRing)) // ensure that Bool[A].asBoolRing is a valid BoolRing - checkAll("Boolean-ring-from-bool", RingLaws[Boolean].boolRing(Bool[Boolean].asBoolRing)) + checkAll("Boolean-ring-from-bool", RingLaws[Boolean].boolRing(new BoolRingFromBool[Boolean](Bool[Boolean]))) // ensure that BoolRing[A].asBool is a valid Bool checkAll("Boolean- bool-from-ring", LogicLaws[Boolean].bool(new BoolFromBoolRing(booleanRing))) @@ -91,7 +91,7 @@ class LawTests extends munit.DisciplineSuite { checkAll("Set[Byte]", LogicLaws[Set[Byte]].generalizedBool) checkAll("Set[Byte]", RingLaws[Set[Byte]].boolRng(setBoolRng[Byte])) checkAll("Set[Byte]-bool-from-rng", LogicLaws[Set[Byte]].generalizedBool(new GenBoolFromBoolRng(setBoolRng))) - checkAll("Set[Byte]-rng-from-bool", RingLaws[Set[Byte]].boolRng(GenBool[Set[Byte]].asBoolRing)) + checkAll("Set[Byte]-rng-from-bool", RingLaws[Set[Byte]].boolRng(new BoolRngFromGenBool(GenBool[Set[Byte]]))) checkAll("Set[Int]", OrderLaws[Set[Int]].partialOrder) checkAll("Set[Int]", RingLaws[Set[Int]].semiring) checkAll("Set[String]", RingLaws[Set[String]].semiring)