let filter_map xs ~f = let rec aux i = match next xs with | Some x -> ( match f x with | None -> aux i | x -> x ) | None -> None in from aux