provide and document lazy-lens and rec-lens

This commit is contained in:
AlexKnauth 2015-09-02 11:50:31 -04:00
parent 10075ef4b0
commit 3336666f40
3 changed files with 35 additions and 0 deletions

33
unstable/lens/lazy.scrbl Normal file
View File

@ -0,0 +1,33 @@
#lang scribble/manual
@(require lens/private/doc-util/main)
@title{Lazy lenses and recursive lenses}
@defmodule[unstable/lens/lazy]
@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-mapper-lens item-lens)
(rec-lens the-tree-lens
(lens-cond [list? (mapper-lens the-tree-lens)]
[else item-lens])))
(lens-view (tree-mapper-lens symbol->string-lens) '(a (b (() c)) (d)))
(lens-set (tree-mapper-lens symbol->string-lens)
'(a (b (() c)) (d))
'("hay" ("bee" (() "sea")) ("deep")))
]}

View File

@ -4,6 +4,7 @@
"if.rkt"
"isomorphism.rkt"
"join-assoc.rkt"
"lazy.rkt"
"mapper.rkt"
"match.rkt"
"set-filterer.rkt"

View File

@ -17,6 +17,7 @@ this library being backwards-compatible.
"if.scrbl"
"isomorphism.scrbl"
"join-assoc.scrbl"
"lazy.scrbl"
"mapper.scrbl"
"match.scrbl"
"set-filterer.scrbl"