{"size": 1097, "ext": "scrbl", "max_stars_repo_path": "lens-doc/lens/private/list/car-cdr.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/car-cdr.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/car-cdr.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": 26.756097561, "max_line_length": 72, "alphanum_fraction": 0.6408386509}
#lang scribble/manual

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

@title[#:tag "pair-lenses"]{Pair lenses}

@deflenses[(car-lens cdr-lens)]{
  Lenses for examining the @racket[car] and @racket[cdr] of
  a pair.
  @lens-examples[
    (lens-view car-lens '(a . b))
    (lens-view cdr-lens '(a . b))
]}


@(define-for-syntax (c_r-lens-id id-stx)
   (format-id id-stx "c~ar-lens" id-stx #:source id-stx #:props id-stx))

@(define-simple-macro (defc_rlenses [c_r-id:id ...] pre-flow ...)
   (deftogether ((defc_rlens c_r-id) ...) pre-flow ...))

@(define-simple-macro (defc_rlens c_r-id)
   #:with c_r-lens (c_r-lens-id #'c_r-id)
   (deflens c_r-lens))

@defc_rlenses[(
  aa ad da dd
  aaa aad ada add
  daa dad dda ddd
  aaaa aaad aada aadd
  adaa adad adda addd
  daaa daad dada dadd
  ddaa ddad ddda dddd)]{
    Lenses for accessing nested pairs. Each lens's view is the
    equivalently named pair-accessor function.
    @lens-examples[
      (cdaddr '(9 8 (6 5 4 3 2 1) 7))
      (lens-view cdaddr-lens '(9 8 (6 5 4 3 2 1) 7))
      (lens-transform cdaddr-lens '(9 8 (6 5 4 3 2 1) 7) list->vector)
]}
