-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from jackfirth/lens-set-all-#13
Add lens-set-all and docs
- Loading branch information
Showing
5 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
(define collection 'multi) | ||
|
||
|
||
(define version "1.1") | ||
(define version "1.2") | ||
|
||
|
||
(define deps | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
]} |