fsprojects / FSharp.Control.AsyncSeq

Asynchronous sequences for F#
https://fsprojects.github.io/FSharp.Control.AsyncSeq/
Other
161 stars 59 forks source link

Changes computation expression's Return to accept only unit. #108

Closed mattstermiller closed 3 years ago

mattstermiller commented 4 years ago

Previously, Return accepted any type at all, but ignores the value. This leads to developers writing code like return 1 which compiles but has no run-time effect, leaving the developer very confused. This computation expression's Return was not intended to be using explicitly with a return keyword but was added to allow the use of do!.

This commit changes Return to only accept unit to no longer allow explicit calls to return passing a value, but continue to allow do!.

Return is being removed from the signature file because of the inability to define the correct type signature. The signature is unit -> AsyncSeq<'T>, but the compiler interprets this as a function that has no parameters rather than a function that has a single parameter of type unit.

mattstermiller commented 4 years ago

I'm not familiar with signature files, but I'm assuming it's the external interface of a module. It looks like removing the Return member means that Return is no longer usable from client code, which I think is a breaking change for clients on older compilers (and clients writing code that uses the return keyword, which almost certainly wrong code because the value is ignored). As such, I don't expect this to be merged as-is, but consider this a plea for help to fix the signature. I've tried everything I can think of, but maybe there is a way to specify the correct type that I don't know of.

dsyme commented 4 years ago

Should we just remove the Return altogether?

dsyme commented 4 years ago

which I think is a breaking change for clients on older compilers

We can use a major version number bump for the package I think, it's an acceptable evolutionary change