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

Add function! (function-bang) keyword to computation expressions #974

Closed
5 tasks done
lucasteles opened this issue Jan 30, 2021 · 2 comments
Closed
5 tasks done

Add function! (function-bang) keyword to computation expressions #974

lucasteles opened this issue Jan 30, 2021 · 2 comments

Comments

@lucasteles
Copy link

Add function! (function-bang) keyword to computation expressions

I propose we extend computation expressions with a new keyword, function! (function-bang), that functions a match! For example, instead of writing:

let createResult = 
    connection  |> createEntityAsync entity
 
match! createResult with
| Error msg -> ..
| Ok _ -> ...
connection
    |> createEntityAsync entity
    |> function!
       | Error msg -> ...
       | Ok _ -> ...

Pros and Cons

Pros: Aids code readability in specialized cases.

Cons: increases complexity.

Extra information

First suggested here

Affidavit (please submit!)

Please tick this by placing a cross in the box:

  • This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
  • I have searched both open and closed suggestions on this site and believe this is not a duplicate
  • 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.

Please tick all that apply:

  • This is not a breaking change to the F# language design
  • I or my company would be willing to help implement and/or test this

For Readers

If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.

@jwosty
Copy link
Contributor

jwosty commented Jan 30, 2021

Interestingly enough, the implementation of match! actually desugars to let! followed by a function instead of match, which is also exactly what this suggestion would do. So this would be pretty easy.

@dsyme
Copy link
Collaborator

dsyme commented Jun 14, 2022

I am generally not in favour of extensive use of function - very occasionally, but it should be rare. So in all cases I would prefer an explicit match!.

For this reason, I will close this.

@dsyme dsyme closed this as completed Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants