3 ms·
FP languages have algebraic data types for this. Why do they call it virtual structs? How are they different than ADTs?
by sepeth 12y ago
FP languages have algebraic data types for this. Why do they call it virtual structs? How are they different than ADTs?
- jarrettc 12y agoRust has algebraic data types. They're one of Rust's most important features. But algebraic data types do not in themselves provide a way to express the notion of a type with variants or sub-types.
- eddyb 12y ago"Virtual Structs" is a name for a potential feature that may expose some sort of structural inheritance or subtyping. The name is not used for the current "enum" feature, which is one of the few ADTs in Rust (there's also "struct" and tuples - not sure what else qualifies).
- pdpi 12y agoenum gives you sum types, struct/tuples provide product types. That's pretty vanilla ADTs sorted. GADTs are a whole other can of worms though.
- cmrx64 12y agoRust enums are ADTs.
- Ygg2 12y agoThis is part one: The good part of Rust's ADT/Enum system. Next I presume is the bad part of it - namely how it caused pain when implementing DOM in Servo.