How to extract a list of field names from a product using mirrors

Does this help?

scala> inline def labelsOf[A](using p: Mirror.ProductOf[A]) = constValueTuple[p.MirroredElemLabels]
def labelsOf[A](using p: deriving.Mirror.ProductOf[A]): p.MirroredElemLabels

scala> case class Point(x: Int, y: Int)
// defined case class Point

scala> labelsOf[Point]
val res4: ("x", "y") = (x,y)

scala> labelsOf[Tuple3[Int, Int, Int]]
val res5: ("_1", "_2", "_3") = (_1,_2,_3)
3 Likes