Skip to content

Commit

Permalink
Merge pull request #256 from jackfirth/255-lens-zoom-examples
Browse files Browse the repository at this point in the history
Clarify zoom lens examples
  • Loading branch information
jackfirth committed Dec 5, 2015
2 parents 99947b3 + b4f15c7 commit 2c73851
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions unstable/lens/zoom.scrbl
Expand Up @@ -15,27 +15,20 @@ is equivalent to:
@racketblock[(lens-transform zoom-lens target (λ (v) (lens-view transform-lens v)))]

@lens-unstable-examples[
(define first-sym->str
(lens-zoom first-lens symbol->string-lens))
(lens-view first-sym->str '(a b c))
(lens-set first-sym->str '(a b c) '("a" b c))
(lens-set first-sym->str '(a b c) '("z" b c))
(lens-set first-sym->str '(a b c) '("z" bee sea))
(lens-view first-sym->str (lens-set first-sym->str '(a b c) '("z" bee sea)))
(define first-zoom-second-lens
(lens-zoom first-lens second-lens))
(lens-view first-zoom-second-lens '((1 2 3) b c))
(lens-set first-zoom-second-lens '((1 2 3) b c) '(2000 b FOO))
]}

@defproc[(lens-zoom* [zoom-lens lens?] [transform-lens lens?] ... ...) lens?]{
A multi-arg version of @racket[lens-zoom], analogous to
@racket[lens-transform/list]. It is equivalent to
@racket[(lens-thrush (lens-zoom zoom-lens transform-lens) ...)].
@lens-unstable-examples[
(define first-sym->str/second-num->str
(lens-zoom* first-lens symbol->string-lens second-lens number->string-lens))
(lens-view first-sym->str/second-num->str '(a 2 c))
(lens-set first-sym->str/second-num->str '(a 2 c) '("a" "2" c))
(lens-set first-sym->str/second-num->str '(a 2 c) '("z" "3" c))
(lens-set first-sym->str/second-num->str '(a 2 c) '("z" "3" sea))
(lens-view first-sym->str/second-num->str
(lens-set first-sym->str/second-num->str '(a 2 c) '("z" "3" sea)))
(define first-zoom-second/third-zoom-first-lens
(lens-zoom* first-lens second-lens
third-lens first-lens))
(lens-view first-zoom-second/third-zoom-first-lens '((1 2 3) foo (a b c)))
(lens-set first-zoom-second/third-zoom-first-lens '((1 2 3) foo (a b c)) '(200 FOO asdf))
]}

0 comments on commit 2c73851

Please sign in to comment.