parent
a4d7cade34
commit
840813724e
|
@ -6,11 +6,17 @@
|
||||||
|
|
||||||
@defproc[(lens/c [target/c contract?] [view/c contract?]) contract?]{
|
@defproc[(lens/c [target/c contract?] [view/c contract?]) contract?]{
|
||||||
A contract constructor for lenses. The @racket[target/c] contract is used for
|
A contract constructor for lenses. The @racket[target/c] contract is used for
|
||||||
the second argument in @racket[(lens-view lens target)], the second argument
|
any target given to or returned by the lens, while the @racket[view/c] contract
|
||||||
and the return value of @racket[(lens-set lens target view)], for example, the
|
is used for any view given to or returned by the lens. For example, the
|
||||||
@racket[view/c] contract is used for the return value of
|
@racket[view/c] contract is used for the return value of
|
||||||
@racket[(lens-view lens target)] and the third argument of
|
@racket[(lens-view lens target)] and the third argument of
|
||||||
@racket[(lens-set lens target view)], as well as other places where targets or
|
@racket[(lens-set lens target view)], as well as other places where targets or
|
||||||
views of the lens are used as inputs or outputs.
|
views of the lens are used as inputs or outputs.
|
||||||
}
|
@lens-examples[
|
||||||
|
(define contracted-car-lens
|
||||||
|
(invariant-assertion (lens/c pair? number?) car-lens))
|
||||||
|
(lens-view contracted-car-lens (cons 1 2))
|
||||||
|
(lens-view contracted-car-lens 'not-a-pair)
|
||||||
|
(lens-view contracted-car-lens (cons 'not-a-number 2))
|
||||||
|
(lens-set contracted-car-lens (cons 1 2) 'not-a-number)
|
||||||
|
]}
|
||||||
|
|
|
@ -9,13 +9,13 @@ require scribble-example
|
||||||
|
|
||||||
|
|
||||||
(define-examples-form lens-examples
|
(define-examples-form lens-examples
|
||||||
lens racket/list racket/vector racket/stream racket/set)
|
lens racket/list racket/vector racket/stream racket/set racket/contract)
|
||||||
|
|
||||||
(define-examples-form lens-applicable-examples
|
(define-examples-form lens-applicable-examples
|
||||||
lens/applicable racket/list racket/vector racket/stream racket/set)
|
lens/applicable racket/list racket/vector racket/stream racket/set racket/contract)
|
||||||
|
|
||||||
(define-examples-form lens-unstable-examples
|
(define-examples-form lens-unstable-examples
|
||||||
lens unstable/lens racket/list racket/vector racket/stream racket/set)
|
lens unstable/lens racket/list racket/vector racket/stream racket/set racket/contract)
|
||||||
|
|
||||||
(define-persistent-examples-form persistent-lens-unstable-examples
|
(define-persistent-examples-form persistent-lens-unstable-examples
|
||||||
lens unstable/lens racket/list racket/vector racket/stream racket/set)
|
lens unstable/lens racket/list racket/vector racket/stream racket/set racket/contract)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user