how is this cast safe? wouldn't this mean that fn should be of type T => traversableOnce[(K, Int)] ?