add lens/c
This commit is contained in:
parent
08423ef11b
commit
e976bea02c
|
@ -12,7 +12,9 @@
|
|||
[focus-lens (-> lens? any/c
|
||||
(values any/c (-> any/c any/c)))]
|
||||
[use-applicable-lenses! (-> void?)]
|
||||
[lens? predicate/c]))
|
||||
[lens? predicate/c]
|
||||
[lens/c (contract? contract? . -> . contract?)]
|
||||
))
|
||||
|
||||
|
||||
(define lenses-applicable? (make-parameter #f))
|
||||
|
@ -27,6 +29,9 @@
|
|||
((lens-struct-get this) target)
|
||||
(error "cannot apply a non-applicable lens as a function"))))
|
||||
|
||||
(define (lens/c target/c view/c)
|
||||
(struct/c lens-struct (-> target/c view/c) (-> target/c view/c target/c)))
|
||||
|
||||
(module+ test
|
||||
(require rackunit)
|
||||
(check-exn exn:fail? (thunk (first-lens '(a b c)))))
|
||||
|
|
16
lens/base/contract.scrbl
Normal file
16
lens/base/contract.scrbl
Normal file
|
@ -0,0 +1,16 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@(require lens/doc-util/main)
|
||||
|
||||
@title{Lens Contracts}
|
||||
|
||||
@defproc[(lens/c [target/c contract?] [view/c contract?]) contract?]{
|
||||
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
|
||||
and the return value of @racket[(lens-set lens target view)], for example, the
|
||||
@racket[view/c] contract is used for the return value 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
|
||||
views of the lens are used as inputs or outputs.
|
||||
}
|
||||
|
|
@ -6,4 +6,5 @@
|
|||
@include-section["view-set.scrbl"]
|
||||
@include-section["laws.scrbl"]
|
||||
@include-section["transform.scrbl"]
|
||||
@include-section["contract.scrbl"]
|
||||
@include-section["compose.scrbl"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user