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 vars to enable terser lens declarations #27

Closed
wants to merge 3 commits into from

Conversation

marcprux
Copy link

Is there any reason vars shouldn't be used in data model structs? The struct will still be immutable in the sense that there is no shared mutable state, and it would permit lenses to be expressed without having the call the struct's initializer for each individual lens.

@CodaFi
Copy link
Member

CodaFi commented Apr 29, 2016

I like the idea of using benign effects to clean up our interface but this permits arbitrary mutation and (mutating) effects to be executed against the lens subject. One of the key points in the README is that our lenses are to be used to subsume the use of mutatable structures. This might make more sense as a motivating example with classes but our goal with structs is to be as immutable as possible both locally and globally.

@marcprux
Copy link
Author

Mutability could be restricted to the module level with internal(set). Might that allay concerns about arbitrary mutation?

@CodaFi
Copy link
Member

CodaFi commented Apr 29, 2016

Mm, could be. If you wanted to include this (for lack of a better word) sugar, break it into its own file and create some documentation showing a motivating use case please. For now, I'd like to leave the existing tests alone but feel free to add your own.

@marcprux
Copy link
Author

OK, I'll play around with it a bit. Thanks for the feedback.

@marcprux marcprux closed this Apr 29, 2016
@CodaFi
Copy link
Member

CodaFi commented Apr 29, 2016

Sounds good. Thanks for your efforts here, I hope we can get something merged. This is a great idea! ✨

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.

None yet

2 participants