Skip to content

Commit 025abc3

Browse files
authored
[v5] Updated Uses of Seq.Append (#290)
* Removed uses of Seq.append * Merge branch 'master' into 'v5-2-seq-fixes'
1 parent da766ed commit 025abc3

File tree

1 file changed

+23
-4
lines changed
  • src/FsToolkit.ErrorHandling

1 file changed

+23
-4
lines changed

src/FsToolkit.ErrorHandling/Seq.fs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// See here for previous design disccusions:
2+
// 1. https://github.com/demystifyfp/FsToolkit.ErrorHandling/pull/277
3+
14
[<RequireQualifiedAccess>]
25
module FsToolkit.ErrorHandling.Seq
36

@@ -62,10 +65,18 @@ let inline traverseResultA' state ([<InlineIfLambda>] f: 'okInput -> Result<'okO
6265
let folder state x =
6366
match state, f x with
6467
| Error errors, Error e ->
65-
Seq.append errors (Seq.singleton e)
68+
seq {
69+
e
70+
yield! Seq.rev errors
71+
}
72+
|> Seq.rev
6673
|> Error
6774
| Ok oks, Ok ok ->
68-
Seq.append oks (Seq.singleton ok)
75+
seq {
76+
ok
77+
yield! Seq.rev oks
78+
}
79+
|> Seq.rev
6980
|> Ok
7081
| Ok _, Error e ->
7182
Seq.singleton e
@@ -167,10 +178,18 @@ let inline traverseAsyncResultA'
167178
return
168179
match state, result with
169180
| Error errors, Error e ->
170-
Seq.append errors (Seq.singleton e)
181+
seq {
182+
e
183+
yield! Seq.rev errors
184+
}
185+
|> Seq.rev
171186
|> Error
172187
| Ok oks, Ok ok ->
173-
Seq.append oks (Seq.singleton ok)
188+
seq {
189+
ok
190+
yield! Seq.rev oks
191+
}
192+
|> Seq.rev
174193
|> Ok
175194
| Ok _, Error e ->
176195
Seq.singleton e

0 commit comments

Comments
 (0)