The problem with unions/enums is that is hard to pick a subset or superset of them, despite it will be not hard to add to any language. Is similar to projection on the relational model (aka:select), sometimes I need:
enum Value {
Int32(i32),
Int64(i32),
Str(String),
}
fn only_int(of:Value[Int32, Int64]) -> Value.Str
And other times: enum ExtraValue:Value {
Bool(bool),
}
This is analog to structs, where eventually is "discovered" that is nice to: let user2 = User {
email: String::from("another@example.com"),
username: String::from("anotherusername567"),
active: user1.active,
sign_in_count: user1.sign_in_count,
};
let user2 = User {
email: String::from("another@example.com"),
username: String::from("anotherusername567"),
..user1
};
But somehow enums are still considered second-class in the algebraic type space.