|
|
|
|
|
by islon
1229 days ago
|
|
No, you cannot. var foo: (T | None) | None = None Which None do you mean here? This is just basic logic: (X or Y) or Y <=> X or Y Untagged unions cannot model that. Contrast it with tagged unions: var foo: Option<Option<T>> = Some(None) var bar: Option<Option<T>> = None Now you can reason about where the None means. |
|
Surely, if you want to distinguish between 3 states you need more data, hence my recommendation of Option<T?>