match value with
| None -> unset key
| Some value -> setter ~key ~value
+let get_opt_default getter default key =
+ match get_opt getter key with
+ | None -> default
+ | Some v -> v
let add_validator ~key ~validator ~descr =
let id = get_next_validator_id () in
* set_* function above. Returned value is a get (set) function typed as the
* given getter (setter) whith optional values. None is returned for missing
* keys and None can be assigned to a key removing it from the registry.
+ *
+ * Sample usage:
+ *
+ * match Helm_registry.get_opt Helm_registry.get_int "foo.bar" with
+ * | Some i -> ...
+ * | None -> ...
*)
val get_opt:
val set_opt:
(key:string -> value:'a -> unit) (* setter *) ->
key:string -> value:'a option -> unit
+val get_opt_default: (* as get_opt with an additional default value *)
+ (string -> 'a) -> 'a -> string -> 'a
(** {2 Validators}
* Each key may have zero or more associated validators, that are predicates