Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access index from the same object #170

Closed
user753 opened this issue Jun 17, 2023 · 3 comments
Closed

How to access index from the same object #170

user753 opened this issue Jun 17, 2023 · 3 comments

Comments

@user753
Copy link

user753 commented Jun 17, 2023

I have this object

case class Foo(foo: List[Int], idx: Int)

How can I create lens like this?

modifyLens[Foo](_.foo.index(_.idx))
@adamw
Copy link
Member

adamw commented Jun 18, 2023

I'm afraid such constructs are not supported by quicklens - so you'll need to handle this by hand.

@user753
Copy link
Author

user753 commented Jun 19, 2023

Thanks. Do you mean like this?

PathLazyModify[Foo, Int]((x, fn) => x.modify(_.foo.index(x.idx)).using(fn))

@adamw
Copy link
Member

adamw commented Jun 23, 2023

Yes, exactly! I'll close this issue since you kind of resolved it yourself :)

@adamw adamw closed this as completed Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants