softwaremill/quicklens

Ability to index into list

zlangbert opened this issue · 5 comments

It would be cool to be able to replace an item in a list, e.g

modify(_: State)(_.someList(i)).setTo(???)
adamw commented

I think it's quite a specialized use-case, no? What would happen if the list doesn't have element i? I'm also afraid about enhancing the API as then you might as well have head, tail methods etc. :)

Specialized for sure. In my case I'm creating a list React elements dynamically and updating their state. I figure it would just throw a NoSuchElementException if it didn't exist. But I would understand not wanting to add this. It's not very safe.

adamw commented

Ok, I understand it might be useful, if somebody someday would like to create a PR, I'll be happy to accept :)

If I am not mistaken, this is what at is doing now since commit 6dc7122, and this issue can be closed now.

adamw commented

true, closing :)