Uh oh!
There was an error while loading. Please reload this page.
[FS-1047] - match! (match-bang) - #4427
Conversation
jwosty
commented
Mar 4, 2018
Here's a quick little sample program using the new syntax for anyone to reference: https://gist.github.com/jwosty/bc7e1723477ea4c300e1fe6a2581d687 |
cartermp
commented
Mar 4, 2018
@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 |
| Async.Sleep 1 | ||
| return Hearts } | ||
| Async.RunSynchronously <| async { |
There was a problem hiding this comment.
can you please reverse it so that it does not use <|
jwosty
commented
Mar 5, 2018
Alright, trying out adding some tests. |
forki
commented
Mar 5, 2018
cool stuff. would love to use it /cc @tpetricek |
jwosty
commented
Mar 5, 2018
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 |
realvictorprm
commented
Mar 5, 2018
@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 |
realvictorprm
commented
Mar 5, 2018
@jwosty that's usually the trick with compilers 😄 |
forki
commented
Mar 5, 2018
@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 |
jwosty
commented
Mar 5, 2018
Also something to keep track of: What tooling changes should take place that would correspond to this? Which repos? |
forki
commented
Mar 5, 2018
@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 |
forki
commented
Mar 5, 2018
@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? |
jwosty
commented
Mar 5, 2018
@forki I see |
@forki It's available in public API via |
forki
commented
Mar 5, 2018
@auduchinok thx @jwosty so you would need to add it here: https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/lexhelp.fs#L396 |
nosami
commented
Mar 5, 2018
forki
commented
Mar 5, 2018
@nosami ideally you should change it to FCS :P |
jwosty
commented
Apr 2, 2018
@dotnet-bot test this please |
Thorium
commented
Apr 17, 2018
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 |
Thorium
commented
Apr 17, 2018
@jwosty I was thinking of match expr2 with!|...similarity of what could be try expr2 with!|...when there is also a |
forki
commented
Apr 17, 2018
via email
That would be try!
Tuomas Hietanen <notifications@github.com> 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>
.
|
PatrickMcDonald
commented
Apr 17, 2018
As Yoda might say:
|
dsyme
commented
May 21, 2018
@jwosty Could you merge with master? thanks |
cartermp
commented
May 21, 2018
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 |
jwosty
commented
May 21, 2018
@dsyme Merged. |
forki
commented
May 22, 2018
via email
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 <notifications@github.com> 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>
.
|
jwosty
commented
May 22, 2018
@forki I mean, I've literally written multiple instances today that need it! I cannot wait to be spoiled by this addition. |
KevinRansom
commented
May 25, 2018
Thank you for this. |
jwosty
commented
May 25, 2018
@KevinRansom of course! Glad to help F# move forward. |
forki
commented
May 25, 2018
via email
Yay!
John Wostenberg <notifications@github.com> 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.
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?
* Attempt add match! syntax to parser (as normal match) (does not work)
* Add name for MATCH_BANG token ("keyword 'match!')
* Make match! valid in (and only in) computational expressions
* match! works
* Add match! to xlf localization files
* Add two tests for match!
* Don't use left-pipe
* Give match! keyword a description
* Fix syntax error, and change match! description
* xlf updated
* Add match! keyword description to resx
* Update FSComp.fs
* Write quotation test for match!
* First crack at compile error tests
* Fix baselines
* Fix baseline one more time
* Add vs baseline
* Fix merge mistake
* Fix merge mistake (#2)
* Fix merge mistake in tests
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)