You can do it in Scala just by forming the intersection type. Subtyping might get in the way (you "lose" types in the intersection which have a subtyping relationship with another) so you can wrap them in an invariant type constructor to work around that.
This gives you a type like `Inv[A] with Inv[B] with Inv[C]`, and you get a subset test "for free", as it's equivalent to taking the supertype.
-
-
You probably want to throw another type into the mix as well (IDK, pick one - it doesn't matter as long as you're consistent and it's got no subtype relationship with `Inv`) so that you have a good representation the empty set.
-
If you want, you could add a type member to an HList and have it form this intersection on the head and the tail (recursively) to get this type automatically.
- Show replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.