Skip to content

Commit

Permalink
Merge pull request #100 from jackfirth/lens-set-all-#13
Browse files Browse the repository at this point in the history
Add lens-set-all and docs
  • Loading branch information
jackfirth committed Jul 11, 2015
2 parents 7df4219 + ca6a12a commit 91de3c7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(define collection 'multi)


(define version "1.1")
(define version "1.2")


(define deps
Expand Down
6 changes: 4 additions & 2 deletions unstable/lens/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
1 change: 1 addition & 0 deletions unstable/lens/main.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
19 changes: 19 additions & 0 deletions unstable/lens/view-set.rkt
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)))
15 changes: 15 additions & 0 deletions unstable/lens/view-set.scrbl
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)
]}

0 comments on commit 91de3c7

Please sign in to comment.