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

Use lenses to permit "focusing" on a State effect #39

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jwiegley
Copy link

@jwiegley jwiegley commented Aug 2, 2022

A draft PR to show the concept....

One of the great things about algebraic effects is that they allow you to focus the range of effects needed by a function to its most limited set: the "weakest precondition of effects", if you will.

This PR shows a simple way to make this idea more flexible. For example, I often have an "application state" carried by an effect State s, but many of my functions need only a part of this state, or they may need those parts only in read-only or append-only terms. It could be that I have a huge state, and my function needs read-only access to one part and read-write access to another part, but none of the rest.

The current freer-simple library already makes this fairly easy to do, but users have to write the reinterpretations themselves. This PR offers a few combinators for lensing into state in these different ways.

I doubt you'd want to include lens as a dependency, but if you think it's useful maybe it could become its own library. I also want to see how this idea plays out in other libraries like fused-effects.

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.

1 participant