dotnet / dotnet/fsharp

Show optional union field names in intellisense

Open
#13,682 1 comment 2 reactions 0 assignees View on GitHub
Area-LangService-AutoComplete Feature Request good first issue help wanted
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

I take advantage of the fact that union fields may optionally be named within each case of a union type, just for readability. I think this is a great feature, as it may not always be obvious just from the type what the field data means. I just learned that these names can actually be used when pattern matching. Here's the example DU taken from the language specification:

```
type Shape =
| Rectangle of width: float * length: float
| Circle of radius: float
| Prism of width: float * float * height: float
```
So, I can construct a Circle with either

`let circle = Circle 1.0`

which of course is probably fine for this simple example, but if I prefer to use the field name for increased readablity:

`let circle = Circle (radius = 1.0)`

The only little hangup with the latter is that the name "radius" does not appear in Intellisense, so I have to remember what name I gave the field. Is this possibly an oversight?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.