I suggest we ...

interpret `do! action` as `let! () = action in zero` when the Builder has no Return defined

In general there are two types of workflows represented by computation expressions:
1) process (async)
2) sequential (seq)

The former usually uses return or return!, the later yield and yield!.

With asyncSeq it's actually a combination of both worlds, but the main purpose is to be sequential, and also allow side effects to happen (do! Async.Sleep 200).

Currently `do! action` is interpreted as `let! () = action in return ()`, with this the Builder has to provide the Return method. With it in place also return keyword becomes available.
In case of asyncSeq the result of `return expr` is completely ignored, what can lead to inconvenience for the users of asyncSeq.

The proposal is to interpret `do! action` as `let! () = action in zero` when the Builder do not provide a Return method.
With it return keyword would be unavailable to the users of the Builder.

Original discussion: https://github.com/fsprojects/FSharp.Control.AsyncSeq/issues/38

3 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Max Malook shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    This PR has been merged, so this design item is completed, though not yet released in a specific version of F#


    This is approved for F# 4.1+. It’s the right adjustment to the language given the problem discussed in the linked gituhb thread

    See also the proposed implementation here: https://github.com/Microsoft/visualfsharp/pull/773
    Don Syme
    F# Language and Core Library Evolution

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...

      F# Language

      Feedback and Knowledge Base