Out of curiosity, are there languages that allow you to do set arithmetic on types to create new types? Something like:  interface A {  void a();  void b();}interface B {  void b();  void c();}interface C = A & B; // has b()interface D = A | B; // has a(), b() and c()interface E = (A & B) ^ B; // has c()I know that in some languages these ideas can be expressed (i.e., Java has List<Comparable & Serializable> for the union of the interfaces) but I've never heard of a language that supports type arithmetic. Thanks!
Are there programming languages that allow you to do set arithmetic on types?
programming languages;type systems
Tangent(0.3 spec) uses something akin to this. (disclaimer: this is my own little research project)Currently with acts as a union operator modelling inheritance, though pragmatism has made it not commutative. Once you introduce implementations to methods, a strict union of methods with the same name is often not what you want and impossible to do right anyways.intersect is supported that models type inference for something like foo(T,T) where the parameters are different.Complements were interesting, but led to partial types that seemed not so useful and/or troublesome to include correctly - so are not included.I know there are a few other research languages I ran across that had something similar, but cannot remember them at the moment. The main issue is that the things aren't really useful without structural typing, which isn't terribly popular itself. The other is that you need some sort of kind (type of types) to store the constructed type, or else it's just shorthand for something that isn't particularly idiomatic without that capability. And that's far less common than even structural typing.It's biased, and it's not much, but there it is.