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

Delicate optics #3454

Merged
merged 6 commits into from
Jun 19, 2024
Merged

Delicate optics #3454

merged 6 commits into from
Jun 19, 2024

Conversation

serras
Copy link
Member

@serras serras commented Jun 13, 2024

(Raised by this Slack conversation)

This PR brings a couple of unlawful optics, namely filtering values and aggregating. These are potentially dangerous in different ways, so they need to be opted-in using DelicateOptic.

@nomisRev I've also renamed the filter functions in the dsl package to filterIndex, as that's the place they make the filtering. That way the new one can get the filter name, which coincides which what you expect from a collection / traversal. AFAIK that filter in the DSL hadn't been released yet, so should be OK changing it.

@serras serras requested review from nomisRev and kyay10 June 13, 2024 19:13
Copy link
Contributor

github-actions bot commented Jun 13, 2024

@kyay10
Copy link
Collaborator

kyay10 commented Jun 15, 2024

Can we have a test showcasing what happens when the optics are used incorrectly? Not super knowledgable about the theory, so I'd like to have examples of incorrect usage and to codify the current behaviour so that it doesn't change unexpectedly

@serras
Copy link
Member Author

serras commented Jun 15, 2024

Can we have a test showcasing what happens when the optics are used incorrectly? Not super knowledgable about the theory, so I'd like to have examples of incorrect usage and to codify the current behaviour so that it doesn't change unexpectedly

I've added the information to the documentation. Furthermore, I've realized that it should not be a prism, but simply an optional. The example was taken from Haskell's optics package.

@nomisRev
Copy link
Member

Furthermore, I've realized that it should not be a prism, but simply an optional.

Cool, I was wondering about that given there was no "constructing" going on.

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice @serras!! 👏 👏

@serras serras merged commit 6b7fe97 into main Jun 19, 2024
11 checks passed
@serras serras deleted the serras/unsafe-optics branch June 19, 2024 07:15
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.

3 participants