You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While writing #77 I realised it would be logical to allow this TaskSeq thing to interoperate with a standard CancellableTask, that is
taskSeq {let!res= cancellableTask {...}...}
which would pass the CancellationToken governing the iteration of the TaskSeq to the Cancellable task. This would give robust cancellation token passing through the overall computation.
Under the alternative long term strategy in #77 this would be the same as
This would mean bringing a CancellableTask into this library from IcedTasks, which may be a good thing.
Hmm, yes. But then the top lib name of TaskSeq should be reconsidered, as the namespace will be hosting tasks and task sequences.
Maybe just FSharp.Control.Tasks and turn it into a collection of all of our wishlist in one place? I.e., cancellable task, parallel task and delayed tasks from IcedTasks and TaskSeq, perhaps later AsyncSeq as well? And then should we include the extremely usefulFsToolkittaskResult and taskOption and the like?
Many questions and strategies possible... Though the idea of a "single stop shop" for all (or most) of task/async related stuff is appealing.
@dsyme, see linked issue by @bartelink, #128. It's now a good time as any to discuss the scope of Task extensions and landing it. It appears that other libraries also yearn for a small, useful extension library.
Not exactly the same as what we discussed here, but this could be a precursor to unifying these efforts at some point.
Thanks for raising this, @dsyme. Here is a current-state analysis:
Current status
The library now supports let! x = someTask inside taskSeq { }, so a CancellableTask (one that accepts a CancellationToken) can already be consumed with a small adaptor:
taskSeq {// manually pass the CT if you have it in scopelet!res= cancellableTask {...} someCancellationToken
yield res
}
However there is no built-in mechanism to forward the sequence's ownCancellationToken (the one passed to GetAsyncEnumerator) into a cancellableTask expression automatically.
What would it take?
To support let! res = cancellableTask { ... } with implicit CT forwarding, the taskSeq builder would need a Bind overload that:
Captures the CT stored in the builder's state at call time.
Invokes the CancellableTask with that CT.
The CT is currently accessible via CancellationToken.None in the enumerator, but there is no way for the CE to implicitly inject it without a dedicated overload.
Related
The discussion in Add better support for cancellation tokens passing #133 on making CancellationToken-passing ergonomic is closely related — the consensus there is to add optional ?ct overloads to TaskSeq module functions. The CancellableTask interop here is a complementary angle for the CE itself.
Bringing CancellableTask in from IcedTasks (as mentioned above) remains a possible longer-term direction, but would widen the scope considerably.
This is a tractable feature to add at the builder level; it just needs a design decision on naming and priority relative to other 0.6.x / vNext work.
Activity
abelbraaksma commentedon Nov 6, 2022
Hmm, yes. But then the top lib name of
TaskSeqshould be reconsidered, as the namespace will be hosting tasks and task sequences.Maybe just
FSharp.Control.Tasksand turn it into a collection of all of our wishlist in one place? I.e., cancellable task, parallel task and delayed tasks fromIcedTasksandTaskSeq, perhaps laterAsyncSeqas well? And then should we include the extremely usefulFsToolkittaskResultandtaskOptionand the like?Many questions and strategies possible... Though the idea of a "single stop shop" for all (or most) of task/async related stuff is appealing.
dsyme commentedon Nov 6, 2022
Yes for the project and nuget something like FSharp.Control.TaskExtras may make sense
We can think it over a bit more but I guess it's OK to go for task/cancellableTask/taskSeq for now.
I'll think about whether it's possible to do an overall revamp for F#8, tailcalls etc too. If we did there would be no harm in a rename then.
abelbraaksma commentedon Dec 14, 2022
@dsyme, see linked issue by @bartelink, #128. It's now a good time as any to discuss the scope of
Taskextensions and landing it. It appears that other libraries also yearn for a small, useful extension library.Not exactly the same as what we discussed here, but this could be a precursor to unifying these efforts at some point.
github-actions commentedon Mar 11, 2026
🤖 This is an automated response from Repo Assist.
Thanks for raising this,
@dsyme. Here is a current-state analysis:Current status
The library now supports
let! x = someTaskinsidetaskSeq { }, so aCancellableTask(one that accepts aCancellationToken) can already be consumed with a small adaptor:However there is no built-in mechanism to forward the sequence's own
CancellationToken(the one passed toGetAsyncEnumerator) into acancellableTaskexpression automatically.What would it take?
To support
let! res = cancellableTask { ... }with implicit CT forwarding, thetaskSeqbuilder would need aBindoverload that:CancellableTaskwith that CT.The CT is currently accessible via
CancellationToken.Nonein the enumerator, but there is no way for the CE to implicitly inject it without a dedicated overload.Related
?ctoverloads toTaskSeqmodule functions. TheCancellableTaskinterop here is a complementary angle for the CE itself.CancellableTaskin from IcedTasks (as mentioned above) remains a possible longer-term direction, but would widen the scope considerably.This is a tractable feature to add at the builder level; it just needs a design decision on naming and priority relative to other 0.6.x / vNext work.
dsyme commentedon Mar 14, 2026
I'm closing as this library focuses on TaskSeq. There's IcedTasks for more