{"size": 1133, "ext": "scrbl", "max_stars_repo_path": "lens-doc/lens/private/list/assoc.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/list/assoc.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/list/assoc.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": 31.4722222222, "max_line_length": 88, "alphanum_fraction": 0.6566637246}
#lang scribble/manual

@(require lens/private/doc-util/main)


@title{Association List Lenses}

@defproc[(assoc-lens [key any/c] [#:is-equal? key-equal? (-> any/c any/c any/c) equal?])
         lens?]{
  Constructs a lens for examining association lists.
  Specifically, for a given association list the returned
  lens examines the second value of the first pair that
  has a key that is @racket[key-equal?] to @racket[key].
  @lens-examples[
    (define assoc-a-lens (assoc-lens 'a))
    (define some-assoc-list '((a . 1) (b . 2) (c . 3)))
    (lens-view assoc-a-lens some-assoc-list)
    (lens-set assoc-a-lens some-assoc-list 100)
  ]
  
  The @racket[key-equal?] procedure is useful for
  datatypes that have their own definition of
  equality, such as strings.
  @lens-examples[
    (define assoc-foo-lens (assoc-lens "foo" #:is-equal? string=?))
    (lens-view assoc-foo-lens '(("bar" . 1) ("foo" . 2) ("baz" . 3)))
]}

@defproc[(assv-lens [key any/c]) lens?]{
  Equivalent to @racket[(assoc-lens key #:is-equal? eqv?)].
}

@defproc[(assq-lens [key any/c]) lens?]{
  Equivalent to @racket[(assoc-lens key #:is-equal? eq?)].
}
