{"size": 944, "ext": "scrbl", "max_stars_repo_path": "lens-doc/lens/private/base/contract.scrbl", "max_stars_repo_name": "AlexKnauth/lens", "max_stars_repo_stars_event_min_datetime": "2015-07-08T12:56:46.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T21:21:54.000Z", "max_issues_repo_path": "lens-doc/lens/private/base/contract.scrbl", "max_issues_repo_name": "AlexKnauth/lens", "max_issues_repo_issues_event_min_datetime": "2015-07-07T01:47:59.000Z", "max_issues_repo_issues_event_max_datetime": "2019-09-10T18:35:17.000Z", "max_forks_repo_path": "lens-doc/lens/private/base/contract.scrbl", "max_forks_repo_name": "AlexKnauth/lens", "max_forks_repo_forks_event_min_datetime": "2015-07-07T05:01:29.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-16T00:37:04.000Z"}
{"max_stars_count": 66, "max_issues_count": 199, "max_forks_count": 11, "avg_line_length": 41.0434782609, "max_line_length": 79, "alphanum_fraction": 0.7394067797}
#lang scribble/manual

@(require lens/private/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
any target given to or returned by the lens, while the @racket[view/c] contract
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[(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.
@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)
]}
