With the following definition it's possible to ensure the concrete type parameters are equal:
trait WithEqual[T1 >: T2 <: T2, T2]
So the line
type A = WithEqual[Int, Int]
will be legal. Now my question is: How to achieve exactly the opposite? Thus, the following line should not compile:
type B = WithUnequal[Int, Int]
This is pretty tricky in Scala, you have to resort to intentional ambiguity. Here's an example of this technique.
Mark Harrah has generalized the trick in his playground for type-level hackery, Up.
It's likely that this could be applied to your question, but I haven't the time to try right now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With