Skip to content

Add a Stdlib module for OCaml < 4.07#5

Merged
2 commits merged intomasterfrom
unknown repository
Aug 29, 2018
Merged

Add a Stdlib module for OCaml < 4.07#5
2 commits merged intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 28, 2018

No description provided.

@ghost ghost mentioned this pull request Aug 28, 2018
Copy link
Copy Markdown
Contributor

@dbuenzli dbuenzli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't have used Stdlabels I think we should rather deprecate it in the future but I won't fight against this.

Except for the variable name this is good to go.

src/dune Outdated
List.filter modules_post_4_02 ~f:(fun (_, v) -> version < v)
|> List.map ~f:fst

let all_modules_expect_stdlib =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be except not expect.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, fixed

@ghost ghost merged commit 31d4ee3 into ocaml:master Aug 29, 2018
@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 29, 2018

I wouldn't have used Stdlabels I think we should rather deprecate it in the future but I won't fight against this.

Out of curiosity, do you think it's the separate Stdlabels module that's bad or the use of labels in general? I don't like having to use a separate module either, but in general I think labels improve readability of the code.

@dbuenzli
Copy link
Copy Markdown
Contributor

Out of curiosity, do you think it's the separate Stdlabels module that's bad or the use of labels in general? I don't like having to use a separate module either, but in general I think labels improve readability of the code.

Both. The dichotomy present in the stdlib about label vs. non label makes it a pain to evolve the stdlib and one more stdlib choice to make for the programmer... Besides I dislike pointless labelling like f in map functions, if your variable names are clear they rather add reading noise in my opinion.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 29, 2018

The main advantage I see of having the f label is that it allows re-ordering the arguments. This is especially nice when the function is big, or when you apply several transformations in a row with |>.

@dbuenzli
Copy link
Copy Markdown
Contributor

I highly dislike the inline function style. Unless the mapped function fits on the line the function should be properly named to indicate to the reader its denotation so that the intent of the map (or fold or whatever) becomes instantaneously readable. As for chaining |> it's not a style that I particularly cherish but in the particular case of the classical map, the signature is in the right order for that.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 29, 2018

I see. I understand your position but I personally don't find it unpleasant to read code written in this style, i.e. with inline functions or using |>.

For the case of the stdlib, given that the compiler doesn't force you to use labels and that their use is often down to personal taste, it seems to me that providing them by default would be better choice than not having them at all.

@dbuenzli
Copy link
Copy Markdown
Contributor

it seems to me that providing them by default would be better choice than not having them at all.

I disagree, the problem with labels is that they leak when you partially apply functions so they somehow go against the idea to use functions as a strong compositional glue. This makes all sorts of functional programming techniques more harder to use (e.g. lifting functions in your applicative functors).

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 29, 2018

I disagree, the problem with labels is that they leak when you partially apply functions they somehow go against the idea to use functions as a strong compositional glue. This makes all sorts of functional programming techniques more harder to use (e.g. lifting functions in your applicative functors).

I understand the part about partially applying functions, and I agree that this is indeed sometimes annoying, however I don't follow the rest, I'd need to see examples to understand the problem better.

Note that we use this style extensively at Jane Street and it works just fine for a whole lot of code.

This pull request was closed.
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.

2 participants