@@ -51,15 +51,17 @@ module List =
5151
5252
5353 let rec private traverseResultA ' state f xs =
54- match xs with
55- | [] -> state |> Result.eitherMap List.rev List.rev
56- | x :: xs ->
54+ match xs with
55+ | [] ->
56+ state
57+ |> Result.eitherMap List.rev List.rev
58+ | x :: xs ->
5759
58- match state, f x with
59- | Ok ys, Ok y -> traverseResultA' ( Ok( y :: ys)) f xs
60- | Error errs, Error e -> traverseResultA' ( Error( e :: errs)) f xs
61- | Ok _, Error e -> traverseResultA' ( Error [ e ]) f xs
62- | Error e, Ok _ -> traverseResultA' ( Error e) f xs
60+ match state, f x with
61+ | Ok ys, Ok y -> traverseResultA' ( Ok( y :: ys)) f xs
62+ | Error errs, Error e -> traverseResultA' ( Error( e :: errs)) f xs
63+ | Ok _, Error e -> traverseResultA' ( Error [ e ]) f xs
64+ | Error e, Ok _ -> traverseResultA' ( Error e) f xs
6365
6466 let rec private traverseAsyncResultA ' state f xs =
6567 match xs with
@@ -70,11 +72,12 @@ module List =
7072 | x :: xs -> async {
7173 let! s = state
7274 let! fR = f x
75+
7376 match s, fR with
7477 | Ok ys, Ok y -> return ! traverseAsyncResultA' ( AsyncResult.retn ( y :: ys)) f xs
7578 | Error errs, Error e ->
7679 return ! traverseAsyncResultA' ( AsyncResult.returnError ( e :: errs)) f xs
77- | Ok _, Error e -> return ! traverseAsyncResultA' ( AsyncResult.returnError [ e ]) f xs
80+ | Ok _, Error e -> return ! traverseAsyncResultA' ( AsyncResult.returnError [ e ]) f xs
7881 | Error e, Ok _ -> return ! traverseAsyncResultA' ( AsyncResult.returnError e) f xs
7982 }
8083
0 commit comments