Stdlib: add Option.try_with
This commit is contained in:
parent
9d30a8f4bf
commit
f10d979432
@ -32,3 +32,5 @@ let first_some a b = match a, b with
|
||||
| None, Some v -> Some v
|
||||
| Some v, _ -> Some v
|
||||
|
||||
let try_with f =
|
||||
try Some (f ()) with _ -> None
|
||||
|
@ -25,3 +25,5 @@ val unopt_map: f:('a -> 'b) -> default:'b -> 'a option -> 'b
|
||||
(** First input of form [Some x], or [None] if none **)
|
||||
val first_some: 'a option -> 'a option -> 'a option
|
||||
|
||||
(** [Some (f ())] if [f] does not raise, [None] otherwise *)
|
||||
val try_with : (unit -> 'a) -> 'a option
|
||||
|
Loading…
Reference in New Issue
Block a user