Add if! (if-bang) keyword to computation expressions
I propose we extend computation expressions with a new keyword, if! (if-bang), that functions a let! (let-bang) combined with an if statement. For example, instead of writing:
let! shouldSolveWorldHunger = confirmAsync ("Solve world hunger?")
if shouldSolveWorldHunger then solveWorldHunger () else dont ()
or even:
match! confirmAsync("Solve world hunger?") with
| true -> solveWorldHunger ()
| false -> dont ()
We should be able to do:
if! confirmAsync("Solve world hunger?") then
solveWorldHunger ()
else dont ()
Pros and Cons
Pros: Aids code readability in specialized cases.
Cons: It's work, and it increases complexity. (whether or not this is worth the effort for potentially such small return is up to debate / whoever would do it, but I figure it's worth filing [probably low priority :) ] since I am not aware of a prior suggestion -- would be brownie points for the F# language)
Extra information
S
Related suggestions: (put links to related suggestions here)
#572
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
Add if! (if-bang) keyword to computation expressions
I propose we extend computation expressions with a new keyword,
if!(if-bang), that functions alet!(let-bang) combined with an if statement. For example, instead of writing:or even:
We should be able to do:
Pros and Cons
Pros: Aids code readability in specialized cases.
Cons: It's work, and it increases complexity. (whether or not this is worth the effort for potentially such small return is up to debate / whoever would do it, but I figure it's worth filing [probably low priority :) ] since I am not aware of a prior suggestion -- would be brownie points for the F# language)
Extra information
S
Related suggestions: (put links to related suggestions here)
#572
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply: