struct
exception No_value of string
let value o ~default = match o with Some s -> s | None -> default
let value_exn o ~msg =
match o with
| Some o -> o
| None -> raise (No_value msg)
let map o ~f =
match o with
| None -> None
| Some s -> Some (f s)
let iter: 'a option -> f:('a -> unit) -> unit = fun o ~f ->
match o with
| None -> ()
| Some s -> f s
let value_map o ~default ~f =
match o with
| Some s -> f s
| None -> default
let return s = Some s
let bind o ~f =
match o with
| None -> None
| Some s -> f s
let (>>=) x f = bind x ~f
end