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.
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.
-
The supertype/subset relationship is the most useful thing you get out of this. Most obviously, you can't remove an element from an intersection type, but that's more to do with sets: If you add ten identical Bippys to a set and remove one, is there a Bippy in the set? Who knows?
- 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.