[SOLVED] Unreducible application of higher-kinded type to wildcard arguments

I am using types to denote dimension. The following code works fine in Scala 3:

  type Dim[T<:Tuple]

  trait LoadedData[S<: Tuple, T <: Dim[S]]
  case object MNIST extends LoadedData[(28,28), Dim[(28,28)]]

But the above is clunky. I want to get rid of the explicit `S’. So I tried removing it. However these don’t work:

  trait LoadedData[T <: Dim[_ <: Tuple]]
  trait LoadedData[T <: Dim[_]]
  case object MNIST extends LoadedData[Dim[(28,28)]]

Obviously I could use a generic invariant type in LoadedData. But is there any way to ensure the <: Dim generic type?


As per the migration notes use a concrete type:

  class Dim[T<:Tuple]

  trait LoadedData[T <: Dim[_], U <: Dataset.Usage]
  case class MNIST[U <: Dataset.Usage]() extends LoadedData[Dim[(28,28)], U]

  val train: LoadedData[Dim[(28,28)], Dataset.Usage.TRAIN.type] = MNIST[Dataset.Usage.TRAIN.type]()

One could also use an abstract class or trait.