fslang-suggestions icon indicating copy to clipboard operation
fslang-suggestions copied to clipboard

Generic equality should use the `SetEquals` method

Open xp44mm opened this issue 7 months ago • 2 comments

I propose we ... (describe your suggestion here)

In .net runtime, there are many Set types that all have SetEquals methods. Generic equality should use the SetEquals method.

    let x = HashSet [1;2;3]
    let y = HashSet [1;2;3]
    Console.WriteLine($"{x=y}")  // false
    Console.WriteLine($"{x.SetEquals y}") // true

The existing way of approaching this problem in F# is ...

Pros and Cons

The advantages of making this adjustment to F# are ...

The disadvantages of making this adjustment to F# are ...

Extra information

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

Related suggestions: (put links to related suggestions here)

Affidavit (please submit!)

Please tick these items 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
  • [ ] This is a language change and not purely a tooling change (e.g. compiler bug, editor support, warning/error messages, new warning, non-breaking optimisation) belonging to the compiler and tooling repository
  • [ ] 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
  • [ ] I have searched both open and closed suggestions on this site and believe this is not a duplicate

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

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.

xp44mm avatar Nov 13 '23 09:11 xp44mm

If this would come, the default analyzers that ship with the compiler should know about it:

if the langversion is < 9 and the fsharp.core version which ships this is used, it should hint that there is a breaking change in behaviour.

We should also consider generating fsproj with the fixed language version rather than latest, if we want to be super conservative and help people be the same, by default, and improve error message when features of new version would make some code compile, but it fails to compile:

Whenever a language version check is done in the compiler leading to an error, through some magic (of algebraic effect, or side, or changing SupportsFeatures call to keep track of things), it would add a final error message showing which language feature check was hit, and mention it in error message, encouraging user to adjust the language version setting.

smoothdeveloper avatar Nov 14 '23 05:11 smoothdeveloper

Easily fixed with #1280

Happypig375 avatar Nov 14 '23 13:11 Happypig375