fsharp / fsharp/fslang-suggestions
Make it more practical for an API to have type, module and/or union case with the same name
- Dominant language
- No language data
- Stars
- 373
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Make it fully practical to use an API that has a type, module and union cases with the same name without opening that module.
Consider this:
```fsharp
module Domain
type TodoID = TodoID of int
module TodoID = let value (TodoID i) = i
```
In this situation it is currently not possible to reference the module from a different source file using a fully qualified name.
For example, try to reference it from a different file using a fully qualified name:
```
module DTO_broken
let ti = Domain.TodoID 1
let i1 = Domain.TodoID.value ti // error FS0039: The field, constructor or member 'value' is not defined.
let i2 = Domain.TodoIDModule.value ti // error FS0039: The value, constructor, namespace or type 'TodoIDModule' is not defined
```
Code does not compile.
Relevant dotnet/fsharp issues
* https://github.com/dotnet/fsharp/issues/9807#issuecomment-679239494
* https://github.com/dotnet/fsharp/issues/8424
* https://github.com/dotnet/fsharp/issues/13122
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Domain/TodoID reproducer and the fully qualified references in DTO_broken to understand the current compiler failure. Read the three linked dotnet/fsharp issues for prior discussion; done means the example compiles and Domain.TodoID.value is usable from another source file without opening the module.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100