ocaml / ocaml

The core OCaml system: compilers, runtime system, base libraries
https://ocaml.org
Other
5.19k stars 1.06k forks source link

add more modules to `StdLabels` / `MoreLabels` #13110

Open anmonteiro opened 3 weeks ago

anmonteiro commented 3 weeks ago

I usually start new projects with -open StdLabels (or include StdLabels, or similar).

Recently, I noticed that e.g. the Seq module doesn't have a labelled version, even though most of its functions are good candidates (like List or Array).

Would it be a welcome addition to add more modules to either StdLabels, MoreLabels or a new module?

nojb commented 2 weeks ago

Personally, I don't have see any problems with doing so. @gasche, @Octachron: do you see any issue with this proposed addition?

gasche commented 2 weeks ago

For users that sounds fine.

It opens a can of bikeshedding worms as we will have to pick new label names, but I think that we should survive this, and the result would be an improvement.

Currently the workflow around *Labels.ml* modules is painful in my opinion, we have an automated script to check for the absence of .mli divergence between the labelled and non-labelled version, and I find it annoying. (I forget to use it, then the CI fails, I'm annoyed, then I have to mirror my changes in the labelled version, and I find the various quirks, and I am more annoyed.) I don't have a clear idea of how to do better. This friction will increase for stdlib contributors if we add more labelled modules.

I think that we did not think of doing this for a while because we collectively assumed that no one really cared about the *Labels modules -- we never get user feedback about them. I would certainly have guessed that label lovers have all migrated to use Core or something. It is useful feedback from @anmonteiro that there is interest in more of it for the standard library.

(Personally I like judicious use of labels and wouldn't mind increased usage of labels in the default modules themselves; for example I rarely remember how to use blit without labels.)

OlivierNicole commented 2 weeks ago

For the record, I personally do care about the labelled modules. I also recall a few posts on Discuss of people saying they like to use them.

If there is no mass feedback about them, maybe it’s because it’s not something that comes to mind when answering to the free-form comments of the OCaml survey? Or maybe they are indeed underused, which may be due to the fact that their existence is hardly publicized (I can’t think of any mention except the one line in the reference documentation of each module).

garrigue commented 2 weeks ago

As a historical comment, all modules were labelized in ocaml 3.00. However, this was reverted in 3.04, and the StdLabels and MoreLabels modules were introduced. At the time, there were no module aliases, so one could not easily produce a separate namespace for labelized versions. This is possible now, so we should be able to produce labelized versions of most modules, and make accessing them easy (i.e. put all of them in StdLabels). There are still some design decisions to be made, such as whether we add one module per original module, as done currently, and keep the ***Labels.mli naming.