-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Reintroduce 'do' keyword as sugar for nested match statements #120
Conversation
|
||
# Motivation | ||
|
||
Flatten code that suffers from 'match pyramids' without loosing the expressiveness of match statements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/loosing/losing/
I would prefer adding the macro instead. If we're going to give this syntax, it should be actual HKT syntax. |
-1 from me. There is no need to introduce an additional keyword when match pyramids can be entirely avoided with Option and Result methods.
I do think that Option and Result methods could use some improvements, and that it's currently time consuming to write code such as the above (mainly due to the lack of an IDE informing the user about the exact return types). |
-1. I have a proposal for a do! {
let a <- action1();
let b <- action2();
action3(a, b);
} Anything implemented before HKTs (and monads) would most likely just be a hack and a leaky abstraction. |
I'm a big fan of the macro given the limitations of today's Rust, but I'd also prefer saving |
-1 the exact same visual effect can be achieved by simply not indenting the "pyramid". |
There are some simple but powerful extensions to Rust's expression level which could also help simplify pattern matching code, discussed previously in some other places which I don't want to go back to look for right now.
Right now you can early return from loops (
Here we can put a refutable pattern on the LHS of a
Here we can make an
This may be familiar from C++'s (Again all of the above syntax is for illustration purposes only and likely has ambiguity issues etc., that's not the point here, only the features themselves.) |
alternative, how about adding sugar for nested match, within the match block itself, keep the 'do' keyword free:
also add an 'match{}else{}' as in the original RFC to catch a fallthrough default. i agree with the comments that HKT is preferable, and the 'do' keyword can find better use |
Having something along these lines would be really useful: the similar monadic Thank you for taking the time to think about these issues, but unfortunately we're going to close as postponed. |
Introduce Route Serializers
Refresh and restructure the Ember CLI Guides
Rendered