baronfel / fsharp-lang-testbed

0 stars 0 forks source link

Catch improper use of monadic return in async #5

Open baronfel opened 7 years ago

baronfel commented 7 years ago

Idea 10256475: Catch improper use of monadic return in async

Status : planned

Submitted by William Blum on 10/17/2015 12:00:00 AM

11 votes

The following code should issue a type checking error since return () should yield an Async and return 42 should yield an Async. let f c = async { return () printfn "You passed %A and I am returning 42" c return 42 } Additionally the following code should issue a warning since the return statement does not actually affect the flow of execution as the name suggests (The printf statement is actually executed). let g c = async { return () printfn "You passed %A and I am returning 42" c return () }

baronfel commented 7 years ago

Comment by Vasily Kirichenko on 10/18/2015 3:09:00 PM

Return in computation expressions is the monodic "return" (or "pure") and has nothing in common with return in imperative languages like C#. What's more, return usually == yield.