typelevel / algebra
 1 ```package algebra ``` 2 ```package lattice ``` 3 4 ```import scala.{specialized => sp} ``` 5 6 ```/** ``` 7 ``` * A bounded lattice is a lattice that additionally has one element ``` 8 ``` * that is the bottom (zero, also written as ⊥), and one element that ``` 9 ``` * is the top (one, also written as ⊤). ``` 10 ``` * ``` 11 ``` * This means that for any a in A: ``` 12 ``` * ``` 13 ``` * join(zero, a) = a = meet(one, a) ``` 14 ``` * ``` 15 ``` * Or written using traditional notation: ``` 16 ``` * ``` 17 ``` * (0 ∨ a) = a = (1 ∧ a) ``` 18 ``` */ ``` 19 ```trait BoundedLattice[@sp(Int, Long, Float, Double) A] extends Any with Lattice[A] with BoundedMeetSemilattice[A] with BoundedJoinSemilattice[A] { self => ``` 20 0 ``` override def dual: BoundedLattice[A] = new BoundedLattice[A] { ``` 21 0 ``` def meet(a: A, b: A) = self.join(a, b) ``` 22 0 ``` def join(a: A, b: A) = self.meet(a, b) ``` 23 0 ``` def one = self.zero ``` 24 0 ``` def zero = self.one ``` 25 ``` override def dual = self ``` 26 ``` } ``` 27 ```} ``` 28 29 ```object BoundedLattice extends ``` 30 ``` BoundedMeetSemilatticeFunctions[BoundedLattice] with ``` 31 ``` BoundedJoinSemilatticeFunctions[BoundedLattice] { ``` 32 33 ``` /** ``` 34 ``` * Access an implicit `BoundedLattice[A]`. ``` 35 ``` */ ``` 36 ``` @inline final def apply[@sp(Int, Long, Float, Double) A](implicit ev: BoundedLattice[A]): BoundedLattice[A] = ev ``` 37 ```} ```

Read our documentation on viewing source code .