diff --git a/unstable/lens/define-nested.scrbl b/unstable/lens/define-nested.scrbl index d4155b5..ebf75fc 100644 --- a/unstable/lens/define-nested.scrbl +++ b/unstable/lens/define-nested.scrbl @@ -20,4 +20,17 @@ For example, if there is a @racket[top] struct containing a Will define @racket[top-middle-x-lens] and @racket[top-middle-y-lens] as @racket[(lens-thrush top-middle-lens middle-x-lens)] and @racket[(lens-thrush top-middle-lens middle-y-lens)]. -} + +@lens-unstable-examples[ + (struct/lens ball (mass position velocity) #:transparent) + (struct/lens position (x y) #:transparent) + (struct/lens velocity (x y) #:transparent) + (define-nested-lenses [ball-pos ball-position-lens] + [x position-x-lens] + [y position-y-lens]) + (define-nested-lenses [ball-vel ball-velocity-lens] + [x velocity-x-lens] + [y velocity-y-lens]) + (lens-view ball-vel-x-lens (ball 1 (position 2 3) (velocity 4 5))) + (lens-set ball-vel-x-lens (ball 1 (position 2 3) (velocity 4 5)) 1004) +]}