Hindley-Milner type systems to the rescue! (With a sprinkling of Haskell style type classes.)
f :: Iterable a => a -> b
f x = (do stuff with x...)
f is defined to be constrained to accept only on types which implement the Iterable interface (however that's defined) as it's first argument and the compiler (or interpreter) will enforce that constraint.