typelevel / algebra
1
package algebra
2
package lattice
3

4
import scala.{specialized => sp}
5

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

10
  override def meetSemilattice: BoundedSemilattice[A] =
11 3
    new BoundedSemilattice[A] {
12 3
      def empty: A = self.one
13 3
      def combine(x: A, y: A): A = meet(x, y)
14
    }
15
}
16

17
trait BoundedMeetSemilatticeFunctions[B[A] <: BoundedMeetSemilattice[A]] extends MeetSemilatticeFunctions[B] {
18
  def one[@sp(Int, Long, Float, Double) A](implicit ev: B[A]): A =
19 0
    ev.one
20
}
21

22
object BoundedMeetSemilattice extends BoundedMeetSemilatticeFunctions[BoundedMeetSemilattice] {
23

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

Read our documentation on viewing source code .

Loading