Match Types: A match type could not be fully reduced

Can someone please help me understand the error below and suggest a workaround? I am trying to extract the return type from F which is either Function0 or Function1

type Out[F] = F match
    case Function0[b] => b
    case Function1[a, b] => b

summon[Out[Int => String] =:= String] // does not compile with following error:

Cannot prove that Out[Int => String] =:= String.

Note: a match type could not be fully reduced:

trying to reduce Out[Int => String]
failed since selector Int => String
does not match case () => b => b
and cannot be shown to be disjoint from it either.
Therefore, reduction cannot advance to the remaining case

case a => b => b

summon[Out[Int => String] =:= String]

Function1 is not disjoint from Function0 since someone could write a class that extends both.

1 Like

Thanks. Any suggestions for the workaround?

I am looking for a meta programming trick to extract the return type from Function0 and Function1.

Use a tried and true typeclass-based approach. Match types will get you nowhere for open types like this.

6 Likes