Skip to content

Commit a96b925

Browse files
committed
Add missing async's Sequential overloads
1 parent 7ebcf50 commit a96b925

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/FSharpPlus/Extensions/Extensions.fs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ module Extensions =
6464
/// Creates a task Choice from a Choice where the Choice1Of2 case is a task.
6565
static member Sequential (t: Choice<Task<'T>, 'Error>) : Task<Choice<'T, 'Error>> = Choice.either (Task.map Choice1Of2) (Task.result << Choice2Of2) t
6666

67+
/// Creates a task option from an option where the Some case is a task.
68+
static member Sequential (t: option<Task<'T>>) : Task<option<'T>> = match t with None -> Task.result None | Some task -> Task.map Some task
69+
70+
/// Creates a task voption from a voption where the ValueSome case is a task.
71+
static member Sequential (t: voption<Task<'T>>) : Task<voption<'T>> = match t with ValueNone -> Task.result ValueNone | ValueSome task -> Task.map ValueSome task
72+
6773
#endif
6874

6975
#if !FABLE_COMPILER
@@ -76,6 +82,12 @@ module Extensions =
7682
/// Creates a task Choice from a Choice where the Choice1Of2 case is a task.
7783
static member Sequential (t: Choice<ValueTask<'T>, 'Error>) : ValueTask<Choice<'T, 'Error>> = Choice.either (ValueTask.map Choice1Of2) (ValueTask.result << Choice2Of2) t
7884

85+
/// Creates a task option from an option where the Some case is a task.
86+
static member Sequential (t: option<ValueTask<'T>>) : ValueTask<option<'T>> = match t with None -> ValueTask.result None | Some task -> ValueTask.map Some task
87+
88+
/// Creates a task voption from a voption where the ValueSome case is a task.
89+
static member Sequential (t: voption<ValueTask<'T>>) : ValueTask<voption<'T>> = match t with ValueNone -> ValueTask.result ValueNone | ValueSome task -> ValueTask.map ValueSome task
90+
7991
#endif
8092

8193
type Async<'t> with
@@ -234,6 +246,12 @@ module Extensions =
234246
| Choice1Of2 a -> Async.Map Choice1Of2 a
235247
| Choice2Of2 e -> async.Return (Choice2Of2 e)
236248

249+
/// Creates an async option from an option where the Some case is async.
250+
static member Sequential (t: Option<Async<'T>>) : Async<Option<'T>> = match t with None -> async.Return None | Some task -> Async.Map Some task
251+
252+
/// Creates an async voption from a voption where the ValueSome case is async.
253+
static member Sequential (t: ValueOption<Async<'T>>) : Async<ValueOption<'T>> = match t with ValueNone -> async.Return ValueNone | ValueSome task -> Async.Map ValueSome task
254+
237255
/// Creates an async Result from a Result where both cases are async.
238256
static member Bisequential (t: Result<Async<'T>, Async<'Error>>) : Async<Result<'T,'Error>> =
239257
match t with

0 commit comments

Comments
 (0)