let apply_opt f v =
  match v with
    | None   -> None
    | Some v -> Some (f v)