You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR proposes to extend the current "symbolic" binding operators (( let+ ), ( let* )) with "named" binding operators (( let/map ), ( let/bind )).
This PR is a reboot of @EduardoRFS's #10979, with a slightly different syntax (the initial proposal was let.map, let.bind proposed by @lpw25 in the broader discussion in #12015. There seems to be a broad consensus (in #10979, #12015 and in #2170) that the current "symbol operators" approach is too limited in terms of readability when mixing several different kinds of bindings, and that named operators would result in more readable code.
The current version does not support "mixed" symbol+names operators such as let/map+ or let/list*, or maybe let+/list and let+/option. The plan is to eventually support a qualified form Option.let/map instead, but I would like to further discuss the syntax for this in #12015 so it is not in the first iteration of the present PR.
See #12015 (comment) for a new discussion item on qualified binding operators (some of Option.let/map, let/Option.map, Option.let+, etc.). I believe that the proposed feature has value even in absence of qualification: it can be used with local opens as we do for binding operators today, and the readability benefits still apply.
(I would still like to think about qualification because I think that Option.let/map or let/Option.map are nicer way to combine several modules than say mixing let/option and let/list.)
The plan is to eventually support a qualified form Option.let/map
My vote would be for let/Option.map even if it expands to Option.(let/map). I think that it is easier to read and it encourages people to define map and let/map as (semantically) the same function in a monad or applicative. That way you can read let/Option.map as essentially doing Option.map, just using a different identifier because e.g. you might want to label the function argument on your actual Option.map.
An alternative would be something like let/Option/map, which isn't too bad.
In any case there are conflicts with the Option.let/map syntax, as discussed in the discussion in #12015 (comment) . (I would rather focus in this PR on the discussion of the feature without module qualification, its desirability of course and its implementation.)
We discussed this PR at the maintainer meeting today. People are generally in favor, but they would like to see support for the qualified syntax, let/Option.map (which desugars into Option.( let/map ) before making a final decision on the feature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes to extend the current "symbolic" binding operators (
( let+ ),( let* )) with "named" binding operators (( let/map ),( let/bind )).This PR is a reboot of @EduardoRFS's #10979, with a slightly different syntax (the initial proposal was
let.map,let.bindproposed by @lpw25 in the broader discussion in #12015. There seems to be a broad consensus (in #10979, #12015 and in #2170) that the current "symbol operators" approach is too limited in terms of readability when mixing several different kinds of bindings, and that named operators would result in more readable code.The current version does not support "mixed" symbol+names operators such as
let/map+orlet/list*, or maybelet+/listandlet+/option. The plan is to eventually support a qualified formOption.let/mapinstead, but I would like to further discuss the syntax for this in #12015 so it is not in the first iteration of the present PR.