The idea would be to add a method to Traverse that lets you update an item at a specific index. I think the signature would be something like this:
def updated[B >: A](fa: F[A], idx: Long, b: B): Option[F[B]] = ???
where it return an None if idx is out-of-range for the collection. I think cats-collections also has an updatedOrThis method.
It should be possible to write a default implementation in terms of mapWithLongIndex via #4245. But then it should be overridden for various collection types to use a more efficient implementation.
The idea would be to add a method to
Traversethat lets you update an item at a specific index. I think the signature would be something like this:where it return an
Noneifidxis out-of-range for the collection. I think cats-collections also has anupdatedOrThismethod.It should be possible to write a default implementation in terms of
mapWithLongIndexvia #4245. But then it should be overridden for various collection types to use a more efficient implementation.