let rec for_all xs ~f = match next xs with | Some x when not (f x) -> false | Some _ -> for_all xs ~f | None -> true