Skip to content

Commit

Permalink
Convert simple Result match to a Result.fold call.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoj613 committed Aug 31, 2024
1 parent 041bc8a commit 7da3c0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions zarr/src/codecs/array_to_bytes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,8 @@ end = struct
let open Util.Result_syntax in
let filter_partition f encoded =
List.fold_right (fun c (l, r) ->
match f c with
| Ok v -> v :: l, r
| Error _ -> l, c :: r) encoded ([], [])
in
Result.fold ~ok:(fun v -> v :: l, r) ~error:(fun _ -> l, c :: r) @@ f c)
encoded ([], []) in
let* codecs = match codecs with
| [] -> Error "No codec chain specified for sharding_indexed."
| y -> Ok y
Expand Down
6 changes: 2 additions & 4 deletions zarr/src/codecs/codecs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ module Chain = struct
let open Util.Result_syntax in
let filter_partition f encoded =
List.fold_right (fun c (l, r) ->
match f c with
| Ok v -> v :: l, r
| Error _ -> l, c :: r) encoded ([], [])
in
Result.fold ~ok:(fun v -> v :: l, r) ~error:(fun _ -> l, c :: r) @@ f c)
encoded ([], []) in
let* codecs = match Yojson.Safe.Util.to_list x with
| [] -> Error "No codec specified."
| y -> Ok y
Expand Down

0 comments on commit 7da3c0c

Please sign in to comment.