typelevel / algebra
1
package algebra
2
package lattice
3

4
import scala.{specialized => sp}
5

6
trait BoundedJoinSemilattice[@sp(Int, Long, Float, Double) A] extends Any with JoinSemilattice[A] { self =>
7
  def zero: A
8 0
  def isZero(a: A)(implicit ev: Eq[A]): Boolean = ev.eqv(a, zero)
9

10
  override def joinSemilattice: BoundedSemilattice[A] =
11 2
    new BoundedSemilattice[A] {
12 2
      def empty: A = self.zero
13 2
      def combine(x: A, y: A): A = join(x, y)
14
    }
15
}
16

17
trait BoundedJoinSemilatticeFunctions[B[A] <: BoundedJoinSemilattice[A]] extends JoinSemilatticeFunctions[B] {
18 0
  def zero[@sp(Int, Long, Float, Double) A](implicit ev: B[A]): A = ev.zero
19
}
20

21
object BoundedJoinSemilattice extends JoinSemilatticeFunctions[BoundedJoinSemilattice]
22
  with BoundedJoinSemilatticeFunctions[BoundedJoinSemilattice] {
23

24
  /**
25
   * Access an implicit `BoundedJoinSemilattice[A]`.
26
   */
27
  @inline final def apply[@sp(Int, Long, Float, Double) A](implicit ev: BoundedJoinSemilattice[A]): BoundedJoinSemilattice[A] = ev
28
}

Read our documentation on viewing source code .

Loading