Skip to content

Add Option.sequenceTask and Option.traverseTask + various permutations #323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tw0po1nt opened this issue Apr 15, 2025 · 0 comments · May be fixed by #325
Open

Add Option.sequenceTask and Option.traverseTask + various permutations #323

tw0po1nt opened this issue Apr 15, 2025 · 0 comments · May be fixed by #325

Comments

@tw0po1nt
Copy link
Contributor

Is your feature request related to a problem? Please describe.

The Option module includes traverse and sequence operations for use with Async (per #298), but not Task. Since the prevailing wisdom for F# code going forward seems to be "prefer Task", having these functions would encourage that choice.

Describe the solution you'd like
I'd like the following functions implemented in the Option module:

// traverseTask: ('a -> Task<'b>) -> 'a option -> Task<'b option>
// sequenceTask:  Task<'a> option -> Task<'a option>

Additionally, some other permutations that would be useful:

To match functions added in #321

// traverseTaskResult: ('a -> Task<Result<'b,'c>>) -> 'a option -> Task<Result<'b option, 'c>>
// sequenceTaskResult:  Task<Result<'a, 'e>> option -> Task<Result<'a option>, 'e>

It could also be useful to have permutations that work with IcedTasks, such as:

// traverseCancellableTaskResult: ('a -> CancellableTask<Result<'b,'c>>) -> 'a option -> CancellableTask<Result<'b option, 'c>>
// sequenceCancellableTaskResult:  CancellableTask<Result<'a, 'e>> option -> CancellableTask<Result<'a option>, 'e>

Since there are a potentially large amount of possible permutations, I'm partial to breaking this into a few issues / PRs, but this at least gets the conversation started.

Describe alternatives you've considered
Custom extensions in each codebase that needs these functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant