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

In scala 3 I have a type T with a Mirror.ProductOf[T]. There is a type on ProductOf named MirroredElemLabels which is type Tuple, which will have Strings in it. I want to reify this into a List[String]. Any ideas on the way to do it?

A quick note, I tried constanatValueTuple or whatever to try to turn said type into a real tuple of strings, but got a nasty compiler error after about commits or some such.

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)
1 Like

Sorry for the late reply, but yes it does. Thank you