-
Notifications
You must be signed in to change notification settings - Fork 790
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
[FS-1047] - match! (match-bang) #4427
Conversation
Here's a quick little sample program using the new syntax for anyone to reference: https://gist.github.com/jwosty/bc7e1723477ea4c300e1fe6a2581d687 |
@jwosty Thanks so much for the contribution! I'm sure @dsyme will offer a thorough review here, and likely have additional ideas about tests. For now, you can add some tests here: https://github.com/Microsoft/visualfsharp/tree/master/tests/fsharp/core/patterns |
tests/fsharp/core/patterns/test.fsx
Outdated
Async.Sleep 1 | ||
return Hearts } | ||
|
||
Async.RunSynchronously <| async { |
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.
can you please reverse it so that it does not use <|
Alright, trying out adding some tests. |
cool stuff. would love to use it /cc @tpetricek |
Me too :) I have a lot of use cases for this in my own projects |
same here. lots and lots of let! followed by match - but inside |
@jwosty ping me for a review, I'll also test it. |
Yep, it works with any computation expression. It's purely a compiler trick that desugars it into a EDIT: technically, it's actually a |
@jwosty that's usually the trick with compilers 😄 |
@jwosty that's pretty nice! |
@realvictorprm I'd love that; I don't actually have easy access to a Windows machine (so its a little trickier to pull off the testing) @forki sweet and simple does the trick! In fact I originally suggested having it optionally emit a new computation builder method (BindPattern or something), but @dsyme wanted to go the simpler route. Makes sense in the end; doesn't require any core library changes |
Also something to keep track of: What tooling changes should take place that would correspond to this? Which repos? |
@jwosty what kind of tooling changes to you mean? |
@forki As in, IDE stuff. E.g. syntax highlighting doesn't recognize it (at least in the way it appears in VS for Mac). Actually, syntax highlighting might be it -- I can't think of how it would effect intellisense |
@jwosty I think VS for Mac can't show it as keyword until @nosami updates the FCS that will bring your changes. So that will take a while. @vasily-kirichenko do you know where FCS taks keywords from? |
@forki I see |
@forki It's available in public API via |
@auduchinok thx @jwosty so you would need to add it here: https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/lexhelp.fs#L396 |
@nosami ideally you should change it to FCS :P |
@dotnet-bot test this please |
Nice! |
@Thorium, that seems just logical to me. I mean, the keyword Might be interesting to consider But apparently I repeat myself and there's already an answer to that from @jwosty:
|
@Thorium Because let! x = expr1
match! expr2 with
| ... looks more consistent, and thus more visually pleasing, than this: let! x = expr1
match expr2 with!
| ... @abelbraaksma I agree, it would be interesting to discuss that -- you should consider starting an fslang-suggestions thread |
@jwosty I was thinking of match expr2 with!
| ... similarity of what could be try expr2 with!
| ... when there is also a |
That would be try!
Tuomas Hietanen <[email protected]> schrieb am Di., 17. Apr. 2018,
17:00:
… @jwosty <https://github.com/jwosty> I was thinking of
match expr2 with!| ...
similarity of what could be
try expr2 with!| ...
when there is also a finally!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4427 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNKRWFDQjycnTD67BvjycqeOrLjsBks5tpgOHgaJpZM4SbN02>
.
|
As Yoda might say:
|
@jwosty Could you merge with master? thanks |
Something is off here, there are far too many changes getting merged in |
@cartermp Ah, that's because I did a squash merge. I should probably roll it back and redo it without squashing. My bad. For cleaner history, I'm gonna force push to delete the merge commit |
@dsyme Merged. |
Really looking forward to getting this in my app. I think I have at least
100 places where it would help. Small addition, but really useful. Thanks
Phillip Carter <[email protected]> schrieb am Mo., 21. Mai 2018,
20:48:
… ***@***.**** approved this pull request.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4427 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNFMDSuPeuk2rQ9C6Nw71z8IvsHPhks5t0wwIgaJpZM4SbN02>
.
|
@forki I mean, I've literally written multiple instances today that need it! I cannot wait to be spoiled by this addition. |
Thank you for this. |
@KevinRansom of course! Glad to help F# move forward. |
Yay!
John Wostenberg <[email protected]> schrieb am Fr., 25. Mai 2018,
05:16:
… @KevinRansom <https://github.com/KevinRansom> of course! Glad to help F#
move forward.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4427 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADgNHbg0Nh3dqlLLRAt-QePHxAia41xks5t13eSgaJpZM4SbN02>
.
|
type CardSuit = | Hearts | Diamonds | Clubs | Spades | ||
let fetchSuit () = async { | ||
// do something in order to not allow optimizing things away | ||
Async.Sleep 1 |
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.
Just noticed -- it should be do! Async.Sleep 1
.
On second thought I'm not sure this is needed at all -- the compiler can't doesn't really optimize let foo () = async { return 42 }
, does it?
RFC FS-1047
I've implemented a version of
match!
that works on my fork.However, since I've been working on Mono & OSX, and I do not have access to a Windows machine for the next few days, I haven't been able to write any kind of tests for this (though I'm not sure where they would go, anyway). Any help or pointers on this matter would be much appreciated (e.g. where are the computational expression tests)