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 Tweet is unavailable.
-
-
Replying to @propensive @contrarivariant
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.
1 reply 0 retweets 0 likes -
Replying to @propensive @contrarivariant
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.
1 reply 0 retweets 0 likes -
Replying to @propensive @contrarivariant
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.
1 reply 0 retweets 0 likes -
Replying to @propensive @contrarivariant
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?
1 reply 1 retweet 0 likes
But I want to experiment with an encoding which is an HList of intersection types, where the set represented by the type is the set of things in the head intersection minus the set of types represented by the tail. The HList gets longer the more times you change the same element.
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.