Registry Mirror
Skip to content

Show optional union field names in intellisense #13682

Open

Description

@jimfoye

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?

Activity

  1. jimfoye commented on Aug 14, 2022

    @jimfoye
    Author

    I was just playing with this again and realized that if hover the mouse over the constructor, I see the union field names. So, the addition to intellisense would be nice just for the sake of autocompletion. But FWIW, I would consider my suggestion to be a pretty low priority.

  2. added this to the Backlog milestone on Aug 16, 2022
  3. pinned this issue on Sep 19, 2022
  4. unpinned this issue on Sep 19, 2022
  5. self-assigned this
    on Sep 30, 2022
  6. modified the milestones: Backlog, December-2022 on Dec 1, 2022
  7. removed their assignment
    on Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions