let rec find_map xs ~f =
  match next xs with
  | Some x -> (
    match f x with
    | Some x as y -> y
    | None -> find_map xs ~f
  )
  | None -> None