Add lens-set-all and docs
This commit is contained in:
parent
7df4219dee
commit
96124baec0
|
@ -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"))
|
||||
|
|
|
@ -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"]
|
||||
|
|
19
unstable/lens/view-set.rkt
Normal file
19
unstable/lens/view-set.rkt
Normal 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)))
|
15
unstable/lens/view-set.scrbl
Normal file
15
unstable/lens/view-set.scrbl
Normal 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)
|
||||
]}
|
Loading…
Reference in New Issue
Block a user