Add lens-set-all and docs

This commit is contained in:
Jack Firth 2015-07-10 18:55:00 -07:00
parent 7df4219dee
commit 96124baec0
4 changed files with 39 additions and 2 deletions

View File

@ -3,9 +3,11 @@
(require "syntax.rkt"
"compound.rkt"
"list.rkt"
"hash.rkt")
"hash.rkt"
"view-set.rkt")
(provide (all-from-out "syntax.rkt"
"compound.rkt"
"list.rkt"
"hash.rkt"))
"hash.rkt"
"view-set.rkt"))

View File

@ -9,6 +9,7 @@ This library provides additional features for the
may change in future releases. Do not depend on
this library being backwards-compatible.
@include-section["view-set.scrbl"]
@include-section["compound.scrbl"]
@include-section["list.scrbl"]
@include-section["hash.scrbl"]

View File

@ -0,0 +1,19 @@
#lang racket
(require lens
fancy-app)
(module+ test
(require rackunit))
(provide
(contract-out
[lens-set-all (->* (any/c any/c) #:rest (listof lens?) any/c)]))
(define (lens-set-all target new-view . lenses)
(foldl (lens-set _ _ new-view) target lenses))
(module+ test
(check-equal? (lens-set-all '(1 2 3 4 5) 'a first-lens third-lens fourth-lens)
'(a 2 a a 5)))

View File

@ -0,0 +1,15 @@
#lang scribble/manual
@(require lens/doc-util/main)
@title{More Viewing and Setting}
@defproc[(lens-set-all [target any/c] [new-view any/c] [lens lens?] ...) any/c]{
Sets the view of @racket[target] through each @racket[lens] to @racket[new--view]
@lenses-unstable-examples[
(lens-set-all '(1 2 3 4 5) 'a
first-lens
third-lens
fourth-lens)
]}