fslaborg / FSharp.Stats

statistical testing, linear algebra, machine learning, fitting and signal processing in F#
https://fslab.org/FSharp.Stats/
Other
205 stars 54 forks source link

[Feature Request] review / remove [<AutoOpen>] on modules that overlay FSharp.Core collection types. #312

Closed smoothdeveloper closed 3 months ago

smoothdeveloper commented 7 months ago

A quick note that I suggest to deprecate the [<AutoOpen>] modules that overlays on FSharp.Core Seq/List/Array.

Without going into details, it is discouraged to open those modules in FSharp.Core, and having FSharp.Stats auto open modules of same names, creates some tooling artifacts.

image

See how it says Seq is unused by being dimmed, but the first one?

If this feels reasonable to most, I'd also like to suggest [<RequireQualifiedAccess>] to tip the thing the other direction, users would always specify Seq., etc. or resort on top level apis for modules that don't overlay on FSharp.Core.

bvenn commented 7 months ago

I totally agree to remove the AutoOpen tags. However I'm not sure if [<RequireQualifiedAccess>] is necessary, as I have no in-depth experience using it. Although I don't see any problems in principle :+1:

smoothdeveloper commented 7 months ago

@bvenn, it occurs that those modules in FSharp.Core have the [] attribute.

open Seq;; -----^^^

error FS0892: This declaration opens the module 'Microsoft.FSharp.Collections.Seq', which is marked as 'RequireQualifiedAccess'. Adjust your code to use qualified references to the elements of the module instead, e.g. 'List.map' instead of 'map'. This change will ensure that your code is robust as new constructs are added to libraries.

I also made a suggestion to component-design-guildelines on F# documentation to be very explicit about the practice of custom modules overlays on existing modules and that would not be consistent in using the attribute.