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

add filterer-lens #147

Closed
wants to merge 2 commits into from
Closed

add filterer-lens #147

wants to merge 2 commits into from

Conversation

AlexKnauth
Copy link
Collaborator

> (lens-view (filterer-lens number?) '(1 a 2 b c 3 d e))
'(1 2 3)
> (lens-set (filterer-lens number?) '(1 a 2 b c 3 d e) '(4 5 6 7))
'(4 5 6 7 a b c d e)

@AlexKnauth
Copy link
Collaborator Author

P.S. I'm not sure: will this filterer-lens always follow the lens laws? (assuming a well-behaved predicate)

@AlexKnauth
Copy link
Collaborator Author

No it won't, because it messes with the order, (lens-set (filterer-lens number?) '(a 1 2 3) (lens-view (filterer-lens number?) '(a 1 2 3))) = '(1 2 3 a), but I meant when order doesn't matter, does it follow them?

@jackfirth
Copy link
Owner

What if only operated on sets? Then I think it would obey the laws. We'd need set lenses though.

@AlexKnauth
Copy link
Collaborator Author

I'm already working on a version for sets.

@AlexKnauth AlexKnauth force-pushed the filterer branch 4 times, most recently from d004b05 to 07ea931 Compare August 19, 2015 23:54
@jackfirth
Copy link
Owner

Given that on lists filter lenses breaks the lens laws, I think we should only make lens constructors for filter/filter-not/partition on sets. It seems counter-intuitive to do it with lists, as with sets lens let you change a subset matching a property but on lists that doesn't feel like it would be a sensible use case.

@jackfirth
Copy link
Owner

Re: partition-lens. Not sure if that would be ugly to use, since lenses can't have multi-value views.

@AlexKnauth
Copy link
Collaborator Author

Ok I'll remove the list ones then.

@AlexKnauth
Copy link
Collaborator Author

The set version is now in #161 .

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