-
Notifications
You must be signed in to change notification settings - Fork 53
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
The focus
(or via
) path operator
#24
Comments
It's not immediately clear to me how that would work (sorry for being slow :) ) - what would be an example result and what would be the signature of |
It would work exactly like implicit class QuicklensFocus[A](val a: A) extends AnyVal {
@compileTimeOnly
def focus[B](lens: Lens[A, B]): B = sys.error("")
} Expanded example: val person = Person(
name = "john",
address = Address(
street = "green street"
)
)
val modified = person
.modifyAll(_.name.focus(EnglishVovels), _.address.street.focus(EnglishVovels))
.using(_.toUpperCase)
modified shouldEqual Person(
name = "jOhn",
address = Address(
street = "grEEn strEEt"
)
) Not seen here, but you can continue traversing the path after a call to |
Thanks! So this would be kind of filtering the "collection" on which |
Yes, the idea is to be able to pass an arbitrary lens to |
This sounds good! Just would need good docs - or rather examples. The two examples (with person and URI) would be great to have in the docs |
This would allow supporting arbitrary lens.
What do you think?
The text was updated successfully, but these errors were encountered: