let take_whilei xs ~f = let aux i = match peek xs with | Some x when f i x -> junk xs ; Some x | _ -> None in from aux