typelevel / algebra
 1 ```package algebra ``` 2 ```package lattice ``` 3 4 ```import scala.{specialized => sp} ``` 5 6 ```/** ``` 7 ``` * A meet-semilattice (or lower semilattice) is a semilattice whose ``` 8 ``` * operation is called "meet", and which can be thought of as a ``` 9 ``` * greatest lower bound. ``` 10 ``` */ ``` 11 ```trait MeetSemilattice[@sp(Int, Long, Float, Double) A] extends Any with Serializable { self => ``` 12 ``` def meet(lhs: A, rhs: A): A ``` 13 14 ``` def meetSemilattice: Semilattice[A] = ``` 15 2 ``` new Semilattice[A] { ``` 16 2 ``` def combine(x: A, y: A): A = self.meet(x, y) ``` 17 ``` } ``` 18 19 ``` def meetPartialOrder(implicit ev: Eq[A]): PartialOrder[A] = ``` 20 0 ``` meetSemilattice.asMeetPartialOrder ``` 21 ```} ``` 22 23 ```trait MeetSemilatticeFunctions[M[A] <: MeetSemilattice[A]] { ``` 24 ``` def meet[@sp(Int, Long, Float, Double) A](x: A, y: A)(implicit ev: M[A]): A = ``` 25 0 ``` ev.meet(x, y) ``` 26 ```} ``` 27 28 ```object MeetSemilattice extends MeetSemilatticeFunctions[MeetSemilattice] { ``` 29 30 ``` /** ``` 31 ``` * Access an implicit `MeetSemilattice[A]`. ``` 32 ``` */ ``` 33 ``` @inline final def apply[@sp(Int, Long, Float, Double) A](implicit ev: MeetSemilattice[A]): MeetSemilattice[A] = ev ``` 34 ```} ```

Read our documentation on viewing source code .