fsharp / fslang-suggestions

The place to make suggestions, discuss and vote on F# language and core library features
344 stars 21 forks source link

Allow record fields to implement signature members #1153

Open dsyme opened 2 years ago

dsyme commented 2 years ago

Currently a record type

type R = { X: int }

Can't implement a signature

type R =
    member X: int

This is perfectly legitimate and useful.

Pros and Cons

The advantages of making this adjustment to F# are signatures are more natural

The disadvantages of making this adjustment to F# are cost

Extra information

Estimated cost (XS, S, M, L, XL, XXL): S

Related suggestions: https://github.com/fsharp/fslang-suggestions/issues/1122

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

For Readers

If you would like to see this issue implemented, please click the :+1: emoji on this issue. These counts are used to generally order the suggestions by engagement.

dsyme commented 2 years ago

There are related questions about whether the record and union patterns (#164, #1152) can be used to implement portions of the corresponding signature patterns.

laurentpayot commented 10 months ago

Any update? Coming from an Elm/PureScript background it’s hard to believe that in F# you can’t use record fields in signatures :astonished:

vzarytovskii commented 10 months ago

Any update? Coming from an Elm/PureScript background it’s hard to believe that in F# you can’t use record fields in signatures :astonished:

It's not being worked on as far as I know. We'll accept RFC and PR, and will help with implementation if anyone's interes.

laurentpayot commented 10 months ago

Fortunately anonymous records are allowed in signatures :relieved: