Skip to content
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 26 commits into from
May 25, 2018
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 Mar 2, 2018
958a208
Add name for MATCH_BANG token ("keyword 'match!')
jwosty Mar 3, 2018
53a67cb
Make match! valid in (and only in) computational expressions
jwosty Mar 3, 2018
96f297b
match! works
jwosty Mar 4, 2018
a3bcd93
Merge remote-tracking branch 'upstream/master' into match-bang
jwosty Mar 4, 2018
8d9ee1b
Add match! to xlf localization files
jwosty Mar 4, 2018
a3e40e0
Add two tests for match!
jwosty Mar 5, 2018
582efb0
Don't use left-pipe
jwosty Mar 5, 2018
353435a
Give match! keyword a description
jwosty Mar 5, 2018
8dc2e5c
Fix syntax error, and change match! description
jwosty Mar 5, 2018
6f21ec7
xlf updated
jindraivanek Mar 7, 2018
4dc2a31
Merge pull request #1 from jindraivanek/xlf
jwosty Mar 7, 2018
772bf52
Add match! keyword description to resx
jwosty Mar 7, 2018
2593cf4
Update FSComp.fs
jwosty Mar 7, 2018
9e6f2dc
Write quotation test for match!
jwosty Mar 7, 2018
c1fd9a8
First crack at compile error tests
jwosty Mar 9, 2018
cb6ea74
Fix baselines
jwosty Mar 9, 2018
596c84e
Fix baseline one more time
jwosty Mar 9, 2018
63ef27b
Add vs baseline
jwosty Mar 9, 2018
0a09ded
Merge branch 'master' into match-bang
jwosty Mar 13, 2018
4308cd0
Merge branch 'master' into match-bang
jwosty Mar 24, 2018
9888a55
Fix merge mistake
jwosty Mar 24, 2018
44f76ba
Fix merge mistake (#2)
Nhowka Apr 2, 2018
a94123e
Fix merge mistake in tests
jwosty Apr 2, 2018
0ef4996
Merge branch 'master' into match-bang
jwosty Apr 10, 2018
fc7916f
Merge branch 'master' into match-bang
jwosty May 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions tests/fsharp/core/patterns/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

@jwosty jwosty Jul 30, 2018

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?

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 {
Copy link
Contributor

@forki forki Mar 5, 2018

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 <|

// 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" *)


Expand Down