Skip to content

Add/use shim versions of FSharp.Core Async and Task modules? #372

Closed

Description

@bartelink

Now that fsharp/fslang-suggestions#1466 fsharp/fslang-suggestions#1467 have made it to fsharp/main, I'm wondering if it might make sense to put poor man's versions of the impls in as shims and then have net11.0 builds use the in the box ones?

Thinking e.g. having clones of Async.Await, Task.parallelLimit in the box conditionally compiled in for <= net11.0 and making the libs internal calls use Async.Await, Async.catch and friends to the max degree possible (which would fix longstanding issues on this lib yielding AggregateException etc.

Or is there a point where the lib simply takes a hard net11 / net12 dependency? (Yes I could search, but more trying to get a quick take from you - I'm not literally as bored as the question might make me seem!)

Activity

  1. changed the title [-]Add shim versions of FSharp.Core Async and Task modules and use same?[/-] [+]Add/use shim versions of FSharp.Core Async and Task modules?[/+] on Sep 8, 2026
  2. TheAngryByrd commented on Sep 9, 2026

    @TheAngryByrd
    Collaborator

    I think this makes sense.

    We already do have the mechanisms for progressive dependency adding so adding F# 11/12 here and adding ifdefs would work.

  3. bartelink commented on Sep 10, 2026

    @bartelink
    ContributorAuthor

    TL;DR which branch/version should a PR target considering I don't personally need it yet and this becomes of minor interest in F#11 release timeframe and major interest in F#12 timeframe. At that point, I can imagine/hope that FSharp.Core will have Async+Task.map2,map3,zip so there may be more than one set of ifdefs (i.e. map gets relegated to a shim when targeting net11.0 and map2 and map3 join it for net12.0).

    Questions

    1. Async.singleton becomes result
      • to what branch do I add the result shim for < net11.0 builds?
      • on that branch, does an obsoleted edition under the old name stay alongside or not?
    2. bind, map get added in FSharp.Core 11, to what branch do I add conditional compiling out for >=net11.0 builds
    3. aside: what does the conditional maxDegreeOfParallelism arg add here in parallelMap. Could I remove it?
    4. Task.catch has a sig change (returns Result) - what branch can that happen in (presumably net11.0 builds exclude it and older ones have the new sig
    5. Task.ignore has a required type attribute in FS Core. what branch could take that [consumption code recompilation] breaking change?
  4. TheAngryByrd commented on Sep 11, 2026

    @TheAngryByrd
    Collaborator

    which branch/version should a PR target, considering

    We're still in beta for 6.0 so just target master and we can add all these shims.

    does an obsoleted edition under the old name stay alongside or not

    It does suck to have binary incompatibilities because people like one name over another any given year. Because this is such a utilized library, I hate making people either be stuck with older versions if they have conflicts or forcing other libraries to update. I'd probably prefer keeping it and sticking whatever Deprecated/Obsolete attribute Microsoft prefers nowadays.

    1. aside: what does the conditional maxDegreeOfParallelism arg add here in parallelMap. Could I remove it?

    Might have been a sloptimization assuming it would allocate less. No preference.

  5. bartelink commented on Sep 11, 2026

    @bartelink
    ContributorAuthor

    Hm well hard choices need to be made for .singleton esp wrt Async/Task/ValueTask (but then logically same for Job/*ResultOption etc)
    I think if we can shim it to provide result universally, then its a win to obsolete result
    But, there is a question as to whether you then document result in the gitbook or let people not targeting FSharp.Core 11.0 work out why they have it despite in not being in the docs

    Ultimately being able to remove docs for empty, result/singleton, map, bind, catch, ignore enhances the value of the docs a lot from my perspective?

    So Task.catch... the FSharp.Core one returns Result.

    • Async.Catch will continue to exist alongside Async.catch with the old signature.
    • For net>=10 I can ifdef it out.
    • But for older ones, I guess the breaking change should be considered? Having something in a common namespace that hides the one everyone will eventually know/use is annoying?

    Another thorny one: Result.valueOr duplicates defaultWith and assume we'd hence want to remove it from the lib and the docs - how do you deal with that?

    • obsolete it in 6.x beta and remove in 7?
    • already remove it from net10/net11 builds in 6.x on the grounds that there is no binary compatibility needed with something that didnt exist?

    => I marked it obsolete and compiled it out on net10

    For Result.map, which has been in FSharp.Core since 6.0 (along with bind and one or two others), there's a different question

    • I guess >=net10 (i.e. newly supported TFMs) can omit it and docs can remove it (and the less functions in the docs the better)
    • for other TFMs, making it BrowserVisible false presumably wont affect the fact that if you open FsToolkit.ErrorHandling the shadowing one will win? and you can't mark it obsolete as there's no easy way to 'correct' the call site using it?

    =>I guess it stays in pre net10.0; But I think it should get removed from the docs along with bind etc?

    Will add more as I run into them...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions