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

Use Fun.id in the documentation of StdLabels #11145

Closed
wants to merge 1 commit into from

Conversation

favonia
Copy link
Contributor

@favonia favonia commented Mar 30, 2022

No description provided.

@nojb
Copy link
Contributor

nojb commented Mar 30, 2022

Hello, thanks for the suggestion. This is kind of subjective, but I find this change gratuitous: there is nothing wrong with the existing code, and the new code does not provide any real improvement either (and it introduces a "dependency" between StdLabels and Fun). All in all, it doesn't seem worth it. Thanks anyway!

@nojb nojb closed this Mar 30, 2022
@gasche
Copy link
Member

gasche commented Mar 30, 2022

My personal rule of the thumb is that Fun.id makes sense in terms that are formed of several combinators to describe transformations, for example Either.map ~left:f ~right:Fun.id, which goes from f : ('a -> 'b) to ('a, 'c) Either.t -> ('b, 'c) Either.t. (We already have a specialized map_left for this, but you get the point of the example.) On the other hand, I avoid it "at the toplevel", when the function I want to describe is the identity (I just write the more readable (fun i -> i); by the way, not sure why (function i -> i) is used here in the documentation, it sounds like a minor style mistake). I think that List.init is in a grey area where one could see it either ways, and in this case I tend to agree that avoiding functions that have to be known from the reader is the best choice.

@favonia
Copy link
Contributor Author

favonia commented Mar 30, 2022

Thanks! Should we change it to fun i -> i, then? I should explain that this PR was inspired by the new documentation on TMC, which uses Fun.id with List.init twice without explanation. I thus got the impression that the documentation of StdLabels could use an update. I don't have a strong opinion, and since I have brought this issue to your (the core developers') attention, I believe I have done my part and should leave further discussions to you.

@favonia favonia deleted the stdlabels branch March 30, 2022 10:53
@gasche
Copy link
Member

gasche commented Mar 30, 2022

Ouch! I wrote the TMC chapter, but I blame @dra27 on this one ( #10740 (comment) ).

In the present case I think that fun i -> i would certainly be an improvement over function i -> i. I only use function when there is a real pattern-matching at play.

@dra27
Copy link
Member

dra27 commented Mar 30, 2022

Blame taken - but FWIW I prefer Fun.id 🙂 I wholeheartedly agree with only using function for pattern matching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants