3 ms·
Technically it's not even one type or another, eg in Rust, Some(1) and None are values of the same type, Option<i32>. What's different is the tag of the enum, o
by sullyj3 7y ago
Technically it's not even one type or another, eg in Rust, Some(1) and None are values of the same type, Option<i32>. What's different is the tag of the enum, or the data constructor, or whatever you want to call it.
- masklinn 7y agoThat’s the reification of it in many langage but at its core what you really want if option is T | (). And some langages do express it that way though mostly for historical reasons of not having sum types and / or being dynamically typed (and there have been rumblings in the past of making rust enum variants into proper types). Of course this is not the case for all enum types. But option / either / result, definitely.
- sullyj3 7y agoSure, namely typescript.