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

Refocus feature #1184

Merged
merged 4 commits into from
Jul 27, 2021
Merged

Refocus feature #1184

merged 4 commits into from
Jul 27, 2021

Conversation

kenbot
Copy link
Collaborator

@kenbot kenbot commented Jul 26, 2021

  • Adds extension method refocus to all optics & applied optics, which is equivalent to optic.andThen(Focus[Foo](_.....)).
  • Resolves [Focus] Mix Focus and standard optics #1056
  • Must be an extension method rather than a direct method on optics, so as to cleanly separate the macro code.
  • Astonishingly, can treat all optics and applied optics uniformly with only one simple implementation.
  • Privately defines a type AnyOptic[S,A] = Setter[S,A] | Fold[S,A] | AppliedSetter[S,A] | AppliedFold[S,A]. Should this be a public definition? Probably not, because its usage is not likely to be meaningful beyond this macro, and would be highly susceptible to change.
  • Big fat test suite testing many combinations of optic types, and especially Getter and Fold, since they are special cases, because their andThen method only has one type parameter.
  • Have not added a Scala 2 equivalent, corresponding to the single-field Focus functionality supported in Scala 2. It makes sense to add this, but perhaps that can be a different ticket

@julien-truffaut
Copy link
Member

Awesome work @kenbot
For Scala 2, maybe we can resurect #1125

I don't have a strong opinion about AnyOptic (public or private)

@julien-truffaut julien-truffaut merged commit 01a952b into optics-dev:master Jul 27, 2021
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

Successfully merging this pull request may close these issues.

[Focus] Mix Focus and standard optics
2 participants