You can do
type Unboxed[B] = B match
case Box[f, a] => f[a]
val result: Option[(Int, String)] =
boxes.map[Unboxed](
[a] => (box: a) => box.asInstanceOf[Box[?, ?]].unbox.asInstanceOf[Unboxed[a]]
)
.mapN((_, _))
I haven’t seen any way that you can work with those fancy tuple methods or implement new ones without a lot of casting…
Shapeless is supposed to have a Scala 3 version with a completely reworked API. I would hope that you can find a well typed API there that can do all these things.