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

as Prism that performs a downcast #1052

Closed
kenbot opened this issue Feb 11, 2021 · 1 comment
Closed

as Prism that performs a downcast #1052

kenbot opened this issue Feb 11, 2021 · 1 comment
Labels
3.x Next major version

Comments

@kenbot
Copy link
Collaborator

kenbot commented Feb 11, 2021

Something like

def as[Source, Target <: Source]: Prism[Source, Target] = {
  Prism[Source, Target](
    source => if (source.isInstanceOf[Target]) Some(source.asInstanceOf[Target]) 
              else None)(
    target => target.asInstanceOf[Source])
}

Also add syntax extension methods on to the optics, in the style of each, some, index, etc. Also, on to the ApplyXXX versions.

It should commute with the Focus macro such that Focus[Foo](_.bar.as[Baz]) == Focus[Foo](_.baz).as[Baz]

@kenbot kenbot added the 3.x Next major version label Feb 11, 2021
@kenbot
Copy link
Collaborator Author

kenbot commented Mar 5, 2021

Resolved by #1110

@kenbot kenbot closed this as completed Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Next major version
Projects
None yet
Development

No branches or pull requests

1 participant