let raise_when_none ?(msg="raise_when_none: the argument is None") (x:'a option) = match x with | Some v -> v | None -> failwith msg