6.2.901.900
5 Struct Lenses
syntax
(struct-lens struct-id field-id)
Returns a lens for viewing the field-id field of a struct-id instance.
Examples:
> (struct foo (a b c) #:transparent)
> (lens-view (struct-lens foo a) (foo 1 2 3)) 1
> (lens-set (struct-lens foo a) (foo 1 2 3) 100) (foo 100 2 3)
syntax
(define-struct-lenses struct-id)
Given a struct-id, defines a lens for each of its fields.
Examples:
> (struct foo (a b c) #:transparent)
> (define-struct-lenses foo)
> (lens-view foo-a-lens (foo 1 2 3)) 1
> (lens-set foo-a-lens (foo 1 2 3) 100) (foo 100 2 3)
syntax
(struct/lens struct-id (field-spec ...) struct-option ...)
Equivalent to struct and define-struct-lenses combined.
Examples:
> (struct/lens foo (a b c) #:transparent)
> (lens-view foo-a-lens (foo 1 2 3)) 1
> (lens-set foo-a-lens (foo 1 2 3) 100) (foo 100 2 3)