-
Notifications
You must be signed in to change notification settings - Fork 802
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
aafdb02
Attempt add match! syntax to parser (as normal match) (does not work)
jwosty 958a208
Add name for MATCH_BANG token ("keyword 'match!')
jwosty 53a67cb
Make match! valid in (and only in) computational expressions
jwosty 96f297b
match! works
jwosty a3bcd93
Merge remote-tracking branch 'upstream/master' into match-bang
jwosty 8d9ee1b
Add match! to xlf localization files
jwosty a3e40e0
Add two tests for match!
jwosty 582efb0
Don't use left-pipe
jwosty 353435a
Give match! keyword a description
jwosty 8dc2e5c
Fix syntax error, and change match! description
jwosty 6f21ec7
xlf updated
jindraivanek 4dc2a31
Merge pull request #1 from jindraivanek/xlf
jwosty 772bf52
Add match! keyword description to resx
jwosty 2593cf4
Update FSComp.fs
jwosty 9e6f2dc
Write quotation test for match!
jwosty c1fd9a8
First crack at compile error tests
jwosty cb6ea74
Fix baselines
jwosty 596c84e
Fix baseline one more time
jwosty 63ef27b
Add vs baseline
jwosty 0a09ded
Merge branch 'master' into match-bang
jwosty 4308cd0
Merge branch 'master' into match-bang
jwosty 9888a55
Fix merge mistake
jwosty 44f76ba
Fix merge mistake (#2)
Nhowka a94123e
Fix merge mistake in tests
jwosty 0ef4996
Merge branch 'master' into match-bang
jwosty fc7916f
Merge branch 'master' into match-bang
jwosty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1311,6 +1311,40 @@ module StructUnionMarshalingBug = | |
let buffer = Marshal.AllocHGlobal(64) // HACK: just assumed a much larger size | ||
Marshal.StructureToPtr<Msg1>(msg1, buffer, false) | ||
|
||
module MatchBangSimple = | ||
type CardSuit = | Hearts | Diamonds | Clubs | Spades | ||
let fetchSuit () = async { | ||
// do something in order to not allow optimizing things away | ||
Async.Sleep 1 | ||
return Some Hearts } | ||
|
||
Async.RunSynchronously <| async { | ||
match! fetchSuit () with | ||
| Some Hearts -> printfn "hearts" | ||
| Some Diamonds | Some Clubs | Some Spades | None -> report_failure "match! matched the wrong case" } | ||
|
||
module MatchBangActivePattern = | ||
type CardSuit = | Hearts | Diamonds | Clubs | Spades | ||
|
||
let (|RedSuit|BlackSuit|) suit = | ||
match suit with | ||
| Hearts | Diamonds -> RedSuit | ||
| Clubs | Spades -> BlackSuit | ||
|
||
let fetchSuit () = async { | ||
Async.Sleep 1 | ||
return Hearts } | ||
|
||
Async.RunSynchronously <| async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you please reverse it so that it does not use <| |
||
// make sure other syntactic elements nearby parse fine | ||
let! x = async.Return 42 | ||
match! fetchSuit () with | ||
| RedSuit as suit -> printfn "%A suit is red" suit | ||
| BlackSuit as suit -> printfn "%A suit is black" suit } | ||
|
||
|
||
|
||
|
||
(* check for failure else sign off "ok" *) | ||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?