-
Notifications
You must be signed in to change notification settings - Fork 8
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
How should we name lenses for improper syntax lists? #292
Comments
It would be tricky to make a lens like this follow the lens laws. What should happen in an example like this? (lens-set list*->list-lens '(a b . c) '(1 2 (3 . 4))) ;; => '(1 2 3 . 4)
(lens-view list*->list-lens '(1 2 3 . 4)) ;; => ??? The answer would be |
That's a very good point, I hadn't thought about this case. An obvious (poor) solution would be to make it a lens constructor, which takes the number of “main” elements as an argument:
This, however, is not very practical if the goal is to be able to use functions like map, length etc. on improper lists. Another poor solution would be to contract the view with For my own use, I think an improper lens would be good enough, but I agree we need something better for the library. Any suggestion? Otherwise I'll close this for now. |
Restricting the view to a proper list seems sensible to me, as the very name itself implies the target is (possibly) improper while the view is proper. In what scenarios would that restriction hinder the ability to use the lens? |
@jackfirth The problem arises when the view is any pair, including if it's a proper list. Consider the following:
I made a mistake, the contract should instead be In the end, the |
Ah, I see the problem now. That revised contract makes sense to me. |
As to the original question - improper list manipulation lenses in general seems like a fine addition to the library. For syntax lists specifically, ideally I'd like to see some way to express For naming: the |
I'd like to add to the lens-data library a few lenses which help manipulating “improper syntax lists”, e.g.
Also, a lens which turns an improper list into a list could be added:
Is there any convention that I should use to refer to improper lists? Or is
list*
a good pick?The text was updated successfully, but these errors were encountered: