{"size": 991, "ext": "scrbl", "max_stars_repo_path": "lens-doc/unstable/lens/lazy.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/unstable/lens/lazy.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/unstable/lens/lazy.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.9677419355, "max_line_length": 80, "alphanum_fraction": 0.6448032291}
#lang scribble/manual

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

@title{Lazy lenses and recursive lenses}

@defform[(lazy-lens lens-expr)]{
Creates a lazy lens that lazily evaluates @racket[lens-expr] and uses it to view
and set the target.
@lens-unstable-examples[
  (define lazy-first-lens
    (lazy-lens (begin (displayln "evaluating") first-lens)))
  lazy-first-lens
  (lens-view lazy-first-lens '(1 2 3))
  (lens-set lazy-first-lens '(1 2 3) 'a)
]}

@defform[(rec-lens rec-id lens-expr)]{
Creates a potentially recursive lens, where @racket[lens-expr] can refer to
@racket[rec-id] as a lazy version of itself.
@lens-unstable-examples[
  (define (tree-map-lens item-lens)
    (rec-lens the-tree-lens
      (lens-cond [list? (map-lens the-tree-lens)]
                 [else item-lens])))
  (lens-view (tree-map-lens symbol->string-lens) '(a (b (() c)) (d)))
  (lens-set (tree-map-lens symbol->string-lens)
            '(a (b (() c)) (d))
            '("hay" ("bee" (() "sea")) ("deep")))
]}
