Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax RequireQualifiedAccess for record expressions #780

debugnik opened this issue Sep 1, 2019 · 1 comment


Copy link

commented Sep 1, 2019

I propose we relax the rules for record types with RequireQualifiedAccess so only one record field needs to be qualified in record expressions.

We can already omit their field qualifiers when the type can be inferred, and a single qualifier is already enough to disambiguate between regular record types too. Thus, asking for every single field to be qualified here seems too verbose.

Short example:

type Foo = { A: int; B: int; C: int }

let zero = { Foo.A = 0; B = 0; C = 0 } // This would work
let setAB a b foo = { foo with Foo.A = a; B = b } // This would work too

Pros and Cons

The advantage of making this adjustment to F# is more ergonomic record expressions when using RequireQualifiedAccess. This may make F# codebases less likely to shy away from them as a tool to introduce records without "polluting" field resolution.

The disadvantage of making this adjustment to F# is implementation cost.

Extra information

Estimated cost (XS, S, M, L, XL, XXL): S? (We already have this for regular records)

Affidavit (please submit!)

Please tick this by placing a cross in the box:

  • This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
  • I have searched both open and closed suggestions on this site and believe this is not a duplicate
  • This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:

  • This is not a breaking change to the F# language design
  • I or my company would be willing to help implement and/or test this

This comment has been minimized.

Copy link

commented Sep 16, 2019

There is overlapping motivation with #722 : being explicit about types. That would help with the first example (let zero = Foo(0, 0, 0)). But with support would be missing: let setAB a b (foo:Foo) = Foo(a, b, foo.C).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.