Type-level filtering tuple in Scala 3

Viewed 95

I've been trying to filter a type-level tuple as suggested by the Tuple.filter documentation, but I've been getting the error Type argument Playground.IsString does not conform to upper bound [_] =>> Boolean. Does anyone know what I'm getting wrong?

The expected result is that I should be able to write Filter[("first", 1, "second", 2), IsString] =:= ("first", "second")

Playground example: https://scastie.scala-lang.org/SQzB9zTPT5ueIqOiXfG4KQ

import scala.Tuple.Filter

type IsString[X] = X match {
  case String => true
  case _ => false
}

abstract class TupleFilter {
  val x: Filter[("first", 1, "second", 2), IsString]
}
0 Answers
Related