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
Copy file name to clipboardExpand all lines: src/FSharpPlus/Extensions/Extensions.fs
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,12 @@ module Extensions =
64
64
/// Creates a task Choice from a Choice where the Choice1Of2 case is a task.
65
65
static memberSequential(t:Choice<Task<'T>,'Error>):Task<Choice<'T, 'Error>>= Choice.either (Task.map Choice1Of2)(Task.result << Choice2Of2) t
66
66
67
+
/// Creates a task option from an option where the Some case is a task.
68
+
static memberSequential(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 memberSequential(t:voption<Task<'T>>):Task<voption<'T>>=match t with ValueNone -> Task.result ValueNone | ValueSome task -> Task.map ValueSome task
72
+
67
73
#endif
68
74
69
75
#if!FABLE_COMPILER
@@ -76,6 +82,12 @@ module Extensions =
76
82
/// Creates a task Choice from a Choice where the Choice1Of2 case is a task.
77
83
static memberSequential(t:Choice<ValueTask<'T>,'Error>):ValueTask<Choice<'T, 'Error>>= Choice.either (ValueTask.map Choice1Of2)(ValueTask.result << Choice2Of2) t
78
84
85
+
/// Creates a task option from an option where the Some case is a task.
86
+
static memberSequential(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 memberSequential(t:voption<ValueTask<'T>>):ValueTask<voption<'T>>=match t with ValueNone -> ValueTask.result ValueNone | ValueSome task -> ValueTask.map ValueSome task
90
+
79
91
#endif
80
92
81
93
typeAsync<'t>with
@@ -234,6 +246,12 @@ module Extensions =
234
246
| Choice1Of2 a -> Async.Map Choice1Of2 a
235
247
| Choice2Of2 e -> async.Return (Choice2Of2 e)
236
248
249
+
/// Creates an async option from an option where the Some case is async.
250
+
static memberSequential(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 memberSequential(t:ValueOption<Async<'T>>):Async<ValueOption<'T>>=match t with ValueNone -> async.Return ValueNone | ValueSome task -> Async.Map ValueSome task
254
+
237
255
/// Creates an async Result from a Result where both cases are async.
0 commit comments