-
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
Should lenses have names for printing? #212
Comments
I like the idea of lens names giving you some information about type, like > (lens-add-type-name "list-ref" lens-expr)
#<lens:list-ref> I'm not sure if we should expose this however. Maybe for now just use it in all our internal functions? |
I was thinking of |
I meant "why not", not "why now" |
Yes that makes more sense to use a symbol. Thinking about it, I haven't got a good reason not to expose it and it makes sense to do so. Nevermind about that point. |
Would it make sense to allow names to be any arbitrary value, to be formatted with |
Possibly. What are some good ways to name lenses we make? |
Would it look better with a space instead of a colon? |
Yes. Is it really a good idea to do this though? What if the values used in constructing the lens aren't printable? |
What do you mean? Do you think someone will do (struct thing ()
#:methods gen:custom-write
[(define (write-proc a b c) (error "not printable"))])
(lens-rename some-lens (thing)) ? And expect it to work? |
I'm less worried about something like that, and more worried that something like |
I'm not saying the name couldn't be a symbol, just that it doesn't have to be. I was looking at contracts and how they print and deal with names. |
Wait why would hash-ref-lens print as ugly? It would be |
Wouldn't it be |
No: > (printf "#<lens ~a>" '(hash-ref-lens 'a))
#<lens (hash-ref-lens 'a)>
> (printf "#<lens ~a>" `(hash-ref-lens ,add1))
#<lens (hash-ref-lens #<procedure:add1>)> |
About composed lenses, I am planning on using |
Should lenses be able to have names for printing?
Would it make any sense to turn
make-lens
into a macro so that it can infer names? (this won't break backwards compatibility by the way if it expands to the procedure)Would it make any sense to (when not given a name) give lenses random
lens1234
names so that they can be distinguished by printing?A
lens-rename
procedure?A
(make-lens getter setter #:name name)
keyword argument?The text was updated successfully, but these errors were encountered: