Skip to content

Commit 4d7bcb8

Browse files
isaacabrahamTheAngryByrd
authored andcommitted
traverseAsyncResultM
1 parent 279f426 commit 4d7bcb8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/FsToolkit.ErrorHandling/List.fs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,20 @@ module List =
2121

2222
let rec private traverseAsyncResultM' (state : Async<Result<_,_>>) (f : _ -> Async<Result<_,_>>) xs =
2323
match xs with
24-
| [] -> state
24+
| [] ->
25+
asyncResult {
26+
let! v = state
27+
return List.rev v
28+
}
2529
| x :: xs ->
2630
async {
2731
let! r = asyncResult {
2832
let! ys = state
2933
let! y = f x
30-
return ys @ [y]
34+
return y :: ys
3135
}
3236
match r with
33-
| Ok _ ->
34-
return! traverseAsyncResultM' (Async.singleton r) f xs
37+
| Ok _ -> return! traverseAsyncResultM' (Async.singleton r) f xs
3538
| Error _ -> return r
3639
}
3740

0 commit comments

Comments
 (0)