Reducing nested Tuple.Map / Tuple.InverseMap types

scala> def f[T <: Tuple]: Tuple.Map[Tuple.InverseMap[Tuple.Map[T, Option], Option], Seq] = ???
def f[T <: Tuple]: Tuple.Map[Tuple.InverseMap[Tuple.Map[T, Option], Option], Seq]

Compiler does’t know that this is just Tuple.Map[T, Seq], but let’s see if it will work anyway:

scala> def f1: Tuple.Map[(Int, String), Seq] = f[(Int, String)]
def f1: (Seq[Int], Seq[String])

Works as expected. Let’s try generic tuple:

scala> def f2[T <: Tuple]: Tuple.Map[T, Seq] = f[T]
-- [E007] Type Mismatch Error: -------------------------------------------------
1 |def f2[T <: Tuple]: Tuple.Map[T, Seq] = f[T]
  |                                        ^^^^
  |Found:    Tuple.Map[Tuple.InverseMap[Tuple.Map[T, Option], Option], Seq]
  |Required: Tuple.Map[T, Seq]

Nope. Let’s try cast:

scala> def f3[T <: Tuple]: Tuple.Map[T, Seq] = f[T].asInstanceOf[Tuple.Map[T, Seq]]
def f3[T <: Tuple]: Tuple.Map[T, Seq]

Works and runs fine (once f is implemented).

Is there a way to make this work without a cast?

Your failed attempt shows an Option. This seems strange. Just a thought.

Your failed attempt shows an Option. This seems strange. Just a thought.

Why is that strange? Option is just an arbitrarily chosen type constructor.

Hmm. Some form of mono-morphism? You are saying T <: Tuple and use T but then expect T to be Tuple.InverseMap. I get that you want the compiler to figure out Tuple.Map[A<:Tuple[B<:Tuple], F[_]] but I think the compiler is giving a nope on A =:= B.

Not really, I want/expect the compiler to figure out that Tuple.InverseMap[Tuple.Map[T, F[_]], F[_]] =:= T, for any T <: Tuple. I don’t think there is a logical error here?

My apologies, I did no see the Option in the first code line. Ignore.