@@ -33,7 +33,6 @@ trait Lattice[A] {
33
33
/** Merging `right` into `left` has no effect */
34
34
inline def subsumes (right : A ): Boolean = Lattice .this .subsumption(right, left)
35
35
36
- /** Merging `left` and `right` would be strictly larger than right */
37
36
inline def inflates (right : A ): Boolean = ! Lattice .this .subsumption(left, right)
38
37
39
38
@ targetName(" mergeInfix" )
@@ -148,11 +147,16 @@ object Lattice {
148
147
*/
149
148
inline given tupleLattice [T <: Tuple ](using pm : Mirror .ProductOf [T ]): Lattice [T ] = derived
150
149
150
+ inline def derived [T <: Product : Mirror .ProductOf ]: Lattice [T ] = productLattice
151
+
152
+ /** Sum Lattice merges considers later defined (those with larger ordinals) constructors as larger.
153
+ * Notably, this implies `None < Some` for Option and `Left < Right` for Either.
154
+ * For an `enum E { case A, B, C }` it will be `A < B < C` */
151
155
inline def sumLattice [T ](using sm : Mirror .SumOf [T ]): Lattice [T ] =
152
156
val lattices : Tuple = summonAll[Tuple .Map [sm.MirroredElemTypes , Lattice ]]
153
157
new Derivation .SumLattice [T ](sm, lattices)
154
158
155
- inline def derived [T <: Product ](using pm : Mirror .ProductOf [T ]): Lattice [T ] = {
159
+ inline def productLattice [T <: Product ](using pm : Mirror .ProductOf [T ]): Lattice [T ] = {
156
160
val lattices : Tuple = summonAll[Tuple .Map [pm.MirroredElemTypes , Lattice ]]
157
161
val bottoms : Tuple = Derivation .summonAllMaybe[Tuple .Map [pm.MirroredElemTypes , Bottom ]]
158
162
new Derivation .ProductLattice [T ](lattices, bottoms, pm, valueOf[pm.MirroredLabel ])
0 commit comments