Given:
sealed trait F
sealed trait K extends F
case object K1 extends K
sealed trait L extends F
case object L1 extends L
Using the above hierarchy, how can I define a function that, at compile-time, has a List of type A that is either all K's or L's, i.e. the super-type must be either K or L, but not F?
Example:
f(List(K1, K1)) would compile since the list's super-type is K
but
f(List(K1, L1)) would not since the list's super-type is F
Either, though I've never liked its syntax much