Skip to content

Add Traverse#updated #4246

Description

@armanbilge

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions