diff --git a/otherlibs/configurator/src/import.ml b/otherlibs/configurator/src/import.ml index 311b11dd490a..e4eacace61ad 100644 --- a/otherlibs/configurator/src/import.ml +++ b/otherlibs/configurator/src/import.ml @@ -56,6 +56,8 @@ module Option = struct else None + let some x = Some x + let try_with f = match f () with | exception _ -> None diff --git a/otherlibs/configurator/src/v1.ml b/otherlibs/configurator/src/v1.ml index 7e5dc198839f..2069878bd6d3 100644 --- a/otherlibs/configurator/src/v1.ml +++ b/otherlibs/configurator/src/v1.ml @@ -530,20 +530,13 @@ const char *s%i = "BEGIN-%i-false-END"; Io.with_lexbuf_from_file obj_file ~f:(Extract_obj.extract []) |> List.fold_left ~init:Int.Map.empty ~f:(fun acc (key, v) -> Int.Map.update acc ~key ~f:(function - | None -> Some (Ok v) - | Some (Error vs) -> Some (Error (v :: vs)) - | Some (Ok v') -> - Some - ( if v = v' then - Ok v' - else - Error [ v; v' ] ))) + | None -> Some [ v ] + | Some vs -> Some (v :: vs))) in List.mapi vars ~f:(fun i (name, t) -> let raw_vals = match Int.Map.find values i with - | Some (Ok v) -> [ v ] - | Some (Error vs) -> vs + | Some v -> v | None -> die "Unable to get value for %s" name in let parse_val_or_exn f = @@ -572,7 +565,7 @@ const char *s%i = "BEGIN-%i-false-END"; match t with | Type.Switch -> Value.Switch (parse_val_or_exn Bool.of_string) | Int -> Value.Int (parse_val_or_exn Int.of_string) - | String -> String (parse_val_or_exn (fun x -> Some x)) + | String -> String (parse_val_or_exn Option.some) in (name, value))