lens
lens copied to clipboard
add struct->struct-lens
see https://github.com/jackfirth/lens/issues/267
This is meant to be an isomorphism yes? I think allowing field reordering would be good. A contrived use case I can think of off the top of my head is wanting a lens to view a position
struct in reverse order:
(struct position (x y))
(define inverse-pos-lens (struct->struct-lens position position [x y] [y x]))
(lens-view inverse-pos-lens (position 1 2))
What you said in (https://github.com/jackfirth/lens/issues/267#issuecomment-163824481) about lens-join/struct
made me think that of the cases where you might want to re-order the fields, a lot of those could be cases where you might want the freedom and power of (lens-join/struct position position-y-lens position-x-lens)
. I can see those use cases, but I can see many more where you might want (lens-join/struct position (lens-compose negate-lens position-y-lens) position-x-lens)
or something similar.