Replies: 11 comments 13 replies
-
Don't want to derail your thread but it is seems this question: Should we provide more syntax to support a programming idiom that is known to compose poorly? was never raised in the public discussion. |
Beta Was this translation helpful? Give feedback.
-
One thing I dislike here is the
I suspect the answer to that is just "no, users could not wrongly assume that". It just seems like a very unlikely reading of that syntax. |
Beta Was this translation helpful? Give feedback.
-
On the proposal of |
Beta Was this translation helpful? Give feedback.
-
I think Also, I'd like to give an upvote for |
Beta Was this translation helpful? Give feedback.
-
I would like to bring up a point here from a discussion in #2170 @gasche you said there:
Let's project what would happen if we were to merge the current state of that PR as it is today i.e. adding the We could immediately use the letops just by doing e.g. If anything comes out of this current discussion to introduce more syntax about qualified binding operators (there's no guarantee this will happen), we can add the new ops at that time and (optionally) deprecate the I don't think this would be such a horrible outcome? Any thoughts? |
Beta Was this translation helpful? Give feedback.
-
I don't think it is reasonable to forego discussions because we might be able to correct a mistake ten years later at the cost of breaking packages. In particular, any new syntax can shift people preferences. My impression is that both |
Beta Was this translation helpful? Give feedback.
-
My two cents for this discussion:
|
Beta Was this translation helpful? Give feedback.
-
I believe that named binding operators are necessary. Finding "meaningful" symbols is extremely hard. What does However, I agree with @haochenx in that I do not like the proposed syntax here that puts the module name before the By convention, |
Beta Was this translation helpful? Give feedback.
-
My current thinking is that I prefer the |
Beta Was this translation helpful? Give feedback.
-
For professional reasons (the Tezos project) I use binding operators often. And our usage differs from some assumption that's floated around this thread. So here come a data point from a somewhat large project.
We use both Lwt (because we need concurrency, we've needed concurrency for a long time) and Result (because we prefer when the type of a function is informative about possible failures). And unsurprisingly, we use the combination of Lwt+Result. (We also use Option, and occasionally Lwt+Option, but we avoid Result+Option.) We've tried a few things and we came up with some Syntax modules and some coding guidelines.
It works well in that:
(Personal opinion follows.) Short operators and long-named functions are both useful in general. I think the same applies to binding operators. A short |
Beta Was this translation helpful? Give feedback.
-
@gasche about It also behaves like the other binding operators such as |
Beta Was this translation helpful? Give feedback.
-
In #10979, @EduardoRFS proposes "named binding operators" to extend the binding operator from
<keyword> <symbols>
to<keyword> <symbols>? . <lident>
:let.some
orlet*.option
for example. Note that the "name" part (some
,option
) is simply a part of the identifier for the binding operator, it is not interpreted as an identifier it iself.The motivation is to better support situations where several different monads/applicatives are mixed, and/or to make it less scope-polluting to define global binding operators at toplevel scope.
An alternative proposal that has been discussed is to allow to qualify binding operators with module paths:
Option.let*
, which would denote the identifier( let* )
identifier in theOption
module.There are several points worth discussing.
Does allowing module qualification subsume named binding operators?
Let's assume we allow the syntax
<module path> . <binding operator>
for module qualification. Do we still see a need for binding operators, for example for disambiguation within the same module (using identifiers rather than less-clear symbols).Maybe we want to consistently use
let.map
andlet.bind
instead oflet+
andlet*
, and thenOption.let.map
,Option.let.bind
?Is the proposed qualified syntax confusing?
@Octachron remarked that there are two potential disambiguation rules for qualified binding operators:
Option.let* x = t in u
could desugar to either:( Option.let* ) u (fun x -> t)
let open Option in ( let* ) u (fun x -> t)
Everyone agrees I believe that the "qualified lookup" behavior is the right one. And there is little need for the local-open behavior for this syntax, as users can already write
Option.(let* x = t in u)
today. But @Octachron wonder if users could wrongly assume that this is a local open, and be surprised.Beta Was this translation helpful? Give feedback.
All reactions