{"action":"created","issue":{"url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/572","repository_url":"https://api.github.com/repos/fsharp/fslang-suggestions","labels_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/572/labels{/name}","comments_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/572/comments","events_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/572/events","html_url":"https://github.com/fsharp/fslang-suggestions/issues/572","id":230444022,"number":572,"title":"Add match! (match-bang) syntactic sugar to computation expressions [ RFC FS-1047 ]","user":{"login":"jwosty","id":4031185,"avatar_url":"https://avatars3.githubusercontent.com/u/4031185?v=4","gravatar_id":"","url":"https://api.github.com/users/jwosty","html_url":"https://github.com/jwosty","followers_url":"https://api.github.com/users/jwosty/followers","following_url":"https://api.github.com/users/jwosty/following{/other_user}","gists_url":"https://api.github.com/users/jwosty/gists{/gist_id}","starred_url":"https://api.github.com/users/jwosty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwosty/subscriptions","organizations_url":"https://api.github.com/users/jwosty/orgs","repos_url":"https://api.github.com/users/jwosty/repos","events_url":"https://api.github.com/users/jwosty/events{/privacy}","received_events_url":"https://api.github.com/users/jwosty/received_events","type":"User","site_admin":false},"labels":[{"id":465113748,"url":"https://api.github.com/repos/fsharp/fslang-suggestions/labels/approved-in-principle","name":"approved-in-principle","color":"76bf1c","default":false},{"id":752394001,"url":"https://api.github.com/repos/fsharp/fslang-suggestions/labels/area:%20computation-expressions","name":"area: computation-expressions","color":"fef2c0","default":false},{"id":465113750,"url":"https://api.github.com/repos/fsharp/fslang-suggestions/labels/completed","name":"completed","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2017-05-22T16:04:10Z","updated_at":"2018-05-29T23:12:38Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"# Add a `match!` syntactic sugar to computation expressions\r\n\r\nWhen writing computation expressions, especially asyncs that call my own functions returning `Option`s, I find myself quite often binding it (via `let!`), then proceeding to use that variable only one time in a pattern match immediately following. It'd be really nice to eliminate the unnecessary `let!` and have a sort of `match!` that means the same thing as a `let!` followed by a vanilla `match`.\r\n\r\nFor example, this:\r\n\r\n```fsharp\r\n(val myAsyncTryGetResult: 'a -> Async<'a option>)\r\nasync {\r\n    let! x = myAsyncTryGetResult foo\r\n    match x with\r\n    | Some(x) -> printfn \"got some: %A\" x\r\n    | None -> printfn \"got none\" }\r\n```\r\n\r\ncould instead be written as:\r\n\r\n```fsharp\r\n(val myAsyncTryGetResult: 'a -> Async<'a option>)\r\nasync {\r\n    match! myAsyncTryGetResult foo with\r\n    | Some(x) -> printfn \"got some: %A\" x\r\n    | None -> printfn \"got none\" }\r\n```\r\n\r\nTo implement this, the compiler could by default treat it the same as `let!` followed by `match`, <s>or spit out a call to a new builder method for this construct if the builder defines it, perhaps called `BindPattern`. It would be identical in signature to `builder.Bind`.\r\n\r\nE.g. compiler could emit\r\n\r\n```fsharp\r\nasyncBuilder.Bind(myAsyncTryGetResult foo, (fun x -> match x with ... ))\r\n```\r\nor\r\n```fsharp\r\nasyncBuilder.BindPattern(myAsyncTryGetResult foo, (fun x -> match x with ... ))\r\n```\r\n</s>\r\n\r\n## Pros and Cons \r\n\r\nThe advantages of making this adjustment to F# are\r\n- Code that encounters this type of annoyance would be a little cleaner\r\n- Non-invasive and simple\r\n\r\nThe disadvantages of making this adjustment to F# are\r\n- Nonzero effort required :P\r\n\r\n## Extra information\r\n\r\nEstimated cost (XS, S, M, L, XL, XXL): S\r\n\r\n## Affadavit (must be submitted)\r\n\r\nPlease tick this by placing a cross in the box:\r\n* [x] This is not a question (e.g. like one you might ask on [stackoverflow](http://stackoverflow.com)) and I have searched stackoverflow for discussions of this issue\r\n* [x] I have [searched both open and closed suggestions on this site](http://github.com/fsharp/fslang-suggestions/issues) and believe this is not a duplicate\r\n* [x] This is not something which has obviously \"already been decided\" in previous versions of F#.  If you're questioning a fundamental design decision that has obviously already been taken (e.g. \"Make F# untyped\") then please don't submit it.\r\n\r\nPlease tick all that apply:\r\n* [x] This is not a breaking change to the F# language design\r\n* [x] I would be willing to help implement and/or test this\r\n* [] I or my company would be willing to help crowdfund F# Software Foundation members to work on this\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/comments/392977489","html_url":"https://github.com/fsharp/fslang-suggestions/issues/572#issuecomment-392977489","issue_url":"https://api.github.com/repos/fsharp/fslang-suggestions/issues/572","id":392977489,"user":{"login":"dsyme","id":7204669,"avatar_url":"https://avatars1.githubusercontent.com/u/7204669?v=4","gravatar_id":"","url":"https://api.github.com/users/dsyme","html_url":"https://github.com/dsyme","followers_url":"https://api.github.com/users/dsyme/followers","following_url":"https://api.github.com/users/dsyme/following{/other_user}","gists_url":"https://api.github.com/users/dsyme/gists{/gist_id}","starred_url":"https://api.github.com/users/dsyme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dsyme/subscriptions","organizations_url":"https://api.github.com/users/dsyme/orgs","repos_url":"https://api.github.com/users/dsyme/repos","events_url":"https://api.github.com/users/dsyme/events{/privacy}","received_events_url":"https://api.github.com/users/dsyme/received_events","type":"User","site_admin":false},"created_at":"2018-05-29T23:12:38Z","updated_at":"2018-05-29T23:12:38Z","author_association":"COLLABORATOR","body":"Implementation has been submitted"}}
{"actor":{"display_login":"dsyme"}}