Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Aug 24, 2020
1 parent 1a9bd72 commit f813f1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 2 additions & 0 deletions otherlibs/configurator/src/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ module Option = struct
else
None

let some x = Some x

let try_with f =
match f () with
| exception _ -> None
Expand Down
15 changes: 4 additions & 11 deletions otherlibs/configurator/src/v1.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit f813f1f

Please sign in to comment.