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

[Focus] Mix Focus and standard optics #1056

Closed
julien-truffaut opened this issue Feb 13, 2021 · 2 comments · Fixed by #1184
Closed

[Focus] Mix Focus and standard optics #1056

julien-truffaut opened this issue Feb 13, 2021 · 2 comments · Fixed by #1184
Labels
After 3.0 Wait for user feedback from the 3.0 release

Comments

@julien-truffaut
Copy link
Member

Focus goal is to provide the best syntax for the most common use cases, but we know we will never cover all scenarios.

So at some point, users may need to mix custom optics with Focus, currently they can use andThen:

Focus[Foo](_.some.bar).andThen(customOptic)

customOptic.andThen(Focus[Foo](_.some.bar))

While, it is not too bad, it might be worth adding two methods:

  1. andThen inside of Focus, e.g. Focus[Foo](_.some.bar.andThen(customOptic))
  2. focus on optics/applyOptics, e.g. customOptic.foucs(_.some.bar)

I am not sure these methods are worth the maintaince cost. We can also wait for 3.0 to be released and see the common use cases people have. We don't need to solve everything at once.

cc @yilinwei @kenbot

@yilinwei
Copy link
Collaborator

I think it's worth adding 1. because it allows users to create their own keywords as 'first-class' into the DSL. But with our current encoding, it is a little cumbersome to do because the quasi-quotes only work with an inheritance based approach - any custom user actions will likely change until we're happy with the current optics encoding.

For 'normal' composition, I don't believe it is worth the burden.

My vote is to wait until the encoding is done first; at that point we can have a tutorial to extend the DSL at the same time.

This would be useful for a second reason; which is we don't need to promote all operations into the Focus macro - only those we believe are common enough in general.

@kenbot
Copy link
Collaborator

kenbot commented Feb 14, 2021

I think this feature can wait until after 3.0, we'll see what the users care about.

I don't like customOptic.focus, because focus is already defined as an extension method on everything, and this focus method does a different thing for optics.

@julien-truffaut julien-truffaut added the After 3.0 Wait for user feedback from the 3.0 release label Feb 14, 2021
@kenbot kenbot changed the title Mix Focus and standard optics [Focus] Mix Focus and standard optics Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
After 3.0 Wait for user feedback from the 3.0 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants