Examples of use cases where match types can be used

I have read the dotty documentation on match types - https://dotty.epfl.ch/docs/reference/new-types/match-types.html
I fail to understand their use cases in real world scenarios. Where would I use something like this?

type Elem[X] = X match {
  case String => Char
  case Array[t] => t
  case Iterable[t] => t
}

A few examples in some existing code bases which could make use of this feature or some real world examples would really help me understand the implications and usefulness of this feature.

Hi! I found the following example by Martin Odersky in one of his recent Scala 3 presentations quite illuminating: https://youtu.be/_Rnrx2lo9cw?t=1977

3 Likes