title: dotty / scala3 unmap a mapped tuple type to its constituent types
body: <p>im having trouble unmapping a mapped tuple to its constituent types. How can i implement the <code>read</code> method of <code>Impl[T]</code> in a typesafe way? currently I am just doing it with <code>Tuple.toArray</code> / <code>Tuple.fromArray</code></p>
  <pre><code>trait Reader[A]:
  
    def read: A
  
  
  object Reader:
  
    def apply[T &lt;: Tuple] (columns: Tuple.Map[T, Reader]): Reader[T] = Impl(columns)
  
    private class Impl[T &lt;: Tuple](columns: Tuple.Map[T, Reader]) extends Reader[T]:
  
      def read: T = ???
  </code></pre>
  <p>Edit (1): added not typesafe code</p>
  <pre><code>  private class Impl[T &lt;: Tuple](columns: Tuple.Map[T, Reader]) extends Reader[T]:
      def read: T = 
        val array = 
          columns
            .toArray
            .asInstanceOf[Array[Reader[_]]]
        val read = array.map(_.read)
        val tuple = 
          Tuple
            .fromArray(read)
            .asInstanceOf[T]
        tuple
  </code></pre>
  <p>Edit (2): current incomplete attempt - contains a PolyFunction error</p>
  <pre><code>extension [F[_], T &lt;: Tuple] (mapped: Tuple.Map[T, F]):
  
    def unmap(f: [a] =&gt; F[a] =&gt; a): T = ???
  
  object Reader:
  
    private class Impl[T &lt;: Tuple](columns: Tuple.Map[T, Reader]) extends Reader[T]:
  
      def read: T = 
        val read_column: [a] =&gt; Reader[a] =&gt; a = [a] =&gt; (reader: Reader[a]) =&gt; reader.read
        val tuple: T = columns.unmap(read_column)
        tuple
  
  </code></pre>