Skip to content

Commit 9120572

Browse files
committed
Add missing Sequential overloads
1 parent baac8f2 commit 9120572

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/FSharpPlus/Extensions/Extensions.fs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,18 @@ module Extensions =
291291
then None
292292
else accumulator.Close () |> Array.toSeq |> Some
293293
#endif
294-
294+
295+
static member Sequential (t: Result<option<'t>, 'Error>) : option<Result<'t, 'Error>> =
296+
match t with
297+
| Ok (Some v) -> Some (Ok v)
298+
| Ok None -> None
299+
| Error e -> Some (Error e)
300+
301+
static member Sequential (t: Choice<option<'t>, 'Choice2Of2>) : option<Choice<'t, 'Choice2Of2>> =
302+
match t with
303+
| Choice1Of2 (Some v) -> Some (Choice1Of2 v)
304+
| Choice1Of2 None -> None
305+
| Choice2Of2 e -> Some (Choice2Of2 e)
295306

296307
type ValueOption<'t> with
297308

@@ -320,6 +331,17 @@ module Extensions =
320331
else accumulator.Close () |> Array.toSeq |> ValueSome
321332
#endif
322333

334+
static member Sequential (t: Result<voption<'t>, 'Error>) : voption<Result<'t, 'Error>> =
335+
match t with
336+
| Ok (ValueSome v) -> ValueSome (Ok v)
337+
| Ok ValueNone -> ValueNone
338+
| Error e -> ValueSome (Error e)
339+
340+
static member Sequential (t: Choice<voption<'t>, 'Choice2Of2>) : voption<Choice<'t, 'Choice2Of2>> =
341+
match t with
342+
| Choice1Of2 (ValueSome v) -> ValueSome (Choice1Of2 v)
343+
| Choice1Of2 ValueNone -> ValueNone
344+
| Choice2Of2 e -> ValueSome (Choice2Of2 e)
323345

324346
type Choice<'T1, 'T2> with
325347

0 commit comments

Comments
 (0)