Improve Discriminated Union Type Inference
Sometimes the most logical name for an element of a Discriminated Union (DU), is a common concept such as a list
-- something that you've used before elsewhere.
The only way around the last resolved resolution is either through namespaces, or by adopting a naming convention.
Sometimes getting nagged about name overuse can lead to clearer code, but what if our intention is exactly as
written? In the below, if we named elements to be ListOfA and ListOfB, then the problem goes away.
Sounds and often is simple, but it can lead to additional code noise and moves us away ever so slightly
from the problem domain.
type A =
| List of A list
type B =
| List of B list
let u : B = List() // okay : takes last defined
let v : A = List() // fails : last defined is B
let w = List() : A // fails : ignores hint
let x = A.List() // okay : fully qualified
let y = List([ElementA]) // fails : expects ElementA
note: this request is similar to this accepted request https://fslang.uservoice.com/forums/245727-f-language/suggestions/7138324-record-based-improve-type-inference-bug?tracking_code=3364d3565b19a0c518474dccbc2a1ec0