Skip to content

Add Option.sequenceAsyncResult and Option.traverseAsyncResult #320

@JayWearsSocks

Description

@JayWearsSocks

Is your feature request related to a problem? Please describe.
In #298, sequence and traverse were added for converting Option<Async<'T>> to Async<Option<'T>>, and similar for Result. I'd like to have those functions available for AsyncResult as well.

Describe the solution you'd like
I'd like there to be Option.sequenceAsyncResult and Option.traverseAsyncResult.

Could it be as simple as copying the sequenceAsync definition and replacing the async CE with a asyncResult CE?

Describe alternatives you've considered
My code uses

// previous stages that result in an option
|> Option.map ( // a function that outputs an Async<Result<Option<'ok>, 'error>> )
|> Option.sequenceAsync
|> Async.map Option.sequenceResult 

and I don't think that's very nice :p (EDIT: possibly not even correct... I've changed it to using a match statement. But I think it's still worth having the sequence and traverse)

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions