tags:

views:

114

answers:

1

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]
+10  A: 

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.

retronym