-
Notifications
You must be signed in to change notification settings - Fork 21
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
Allow operators as active patterns #998
Comments
What would happen to the existing pattern match operators |
@7sharp9 |
I meant during the match, as &/| are already allowed. |
It is hard for me to comment without understanding more about code where you'd use it. It would help me if you'd had samples of before/after added to the suggestion. On the syntax, if the semantics are the same as active patterns, I suggest this: let (|a ++ b|) = x |
Here are some cases where I miss this feature:
If I define a
as opposed to
as opposed to
In both cases, having the possibility to use the same operator to deconstruct leads to an API more consistent and therefore easier to use, as we don't have to remember two operations. Contrast it with the |
Interesting idea. I kind of like it 🙂. Not sure if I'd ever use it, but I can see the use here. |
I'm not in favour of extending the role of user-definable symbolic operators in the language like this, into pattern matching. Just use an active pattern. As part of this, I'd kind of like to remove |
Closing all |
Allow operators as active patterns
I propose we allow to define operators as active patterns, so we'll be able to write code like this:
or
This can be defined like
let (| ++ |) x = ...
Pros and Cons
The advantages of making this adjustment to F# are:
The disadvantages of making this adjustment to F# are
Extra information
Estimated cost XS / S:
Related suggestions: none that I know
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
The text was updated successfully, but these errors were encountered: