Skip to content

Commit cd64272

Browse files
roboz0redgarfgp
andauthored
Add FS-1047 (#67)
Adds `match!` keyword per [RFC-1047](https://github.com/fsharp/fslang-design/blob/main/FSharp-4.5/FS-1047-match-bang.md). I'm not quite sure if I've done this one correctly. I didn't exactly understand the "weird section". --------- Co-authored-by: Edgar Gonzalez <egonzalez@totallymoney.com>
1 parent ca37ea7 commit cd64272

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

spec/expressions.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,11 @@ comp-expr :=
135135
use pat = expr in comp-expr
136136
yield! expr -- yield computation
137137
yield expr -- yield result
138-
return! expr -- return computation
138+
return! expr -- return computation
139139
return expr -- return result
140140
if expr then comp - expr -- control flow or imperative action
141141
if expr then expr else comp-expr
142+
match! expr with pat -> comp-expr | ... | pat -> comp-expr
142143
match expr with pat -> comp-expr | ... | pat -> comp-expr
143144
try comp - expr with pat -> comp-expr | ... | pat -> comp-expr
144145
try comp - expr finally expr
@@ -702,6 +703,7 @@ expr { yield! ... }
702703
expr { try ... }
703704
expr { return ... }
704705
expr { return! ... }
706+
expr { match! ... }
705707
```
706708

707709
More specifically, computation expressions have the following form:
@@ -786,6 +788,8 @@ Then, T is defined for each computation expression e:
786788

787789
**T** (match e with pi - > cei, **V** , **C** , q) = **C** (match e with pi - > {| `ce` i |} 0 )
788790

791+
**T** (match! e with pi - > cei, **V** , **C** , q) = **C** (let! p = e in match p with pi - > {| `ce` i |} 0 )
792+
789793
**T** (while e do ce, **V** , **C** , q) = **T** (ce, **V** , v. **C** (b.While(fun () -> e, b.Delay(fun () -> v))), q)
790794

791795
**T** (try ce with pi - > cei, **V** , **C** , q) =

spec/lexical-analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ The following symbolic or partially symbolic character sequences are treated as
309309

310310
```fsgrammar
311311
token symbolic-keyword =
312-
let! use! do! yield! return!
312+
let! use! do! yield! return! match!
313313
| -> <-. : ( ) [ ] [< >] [| |] { }
314314
' # :?> :? :> .. :: := ;; ; =
315315
_? ?? (*) <@ @> <@@ @@>

spec/rfc-status.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
| F# 4.1 | FS-1027 | [Complete Optional DefaultParameterValue](https://github.com/fsharp/fslang-design/tree/main/FSharp-4.1/FS-1027-complete-optional-defaultparametervalue.md) | |
3535
| F# 4.1 | FS-1029 | [Implement IReadOnlyCollection in list](https://github.com/fsharp/fslang-design/tree/main/FSharp-4.1/FS-1029-Implement%20IReadOnlyCollection%20in%20list.md) | |
3636
| F# 4.1 | FS-1040 | [Enum Match](https://github.com/fsharp/fslang-design/tree/main/FSharp-4.1/FS-1040-enum-match.md) | |
37-
| F# 4.5 | FS-1047 | [Match Bang](https://github.com/fsharp/fslang-design/tree/main/FSharp-4.5/FS-1047-match-bang.md) | |
37+
| F# 4.5 | FS-1047 | [Match Bang](https://github.com/fsharp/fslang-design/tree/main/FSharp-4.5/FS-1047-match-bang.md) | [completed](https://github.com/fsharp/fslang-spec/pull/67) |
3838
| F# 4.5 | FS-1053 | [Span](https://github.com/fsharp/fslang-design/tree/main/FSharp-4.5/FS-1053-span.md) | |
3939
| F# 4.5 | FS-1054 | [Undent List Args](https://github.com/fsharp/fslang-design/tree/main/FSharp-4.5/FS-1054-undent-list-args.md) | |
4040
| F# 4.5 | FS-1055 | [Subsumption for Yield in Sequence Expression](https://github.com/fsharp/fslang-design/tree/main/FSharp-4.5/FS-1055-subsumption-for-yield-in-sequence-expression.md) | |

0 commit comments

Comments
 (0)