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 ()
}
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.
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 ()
}