Skip to content

Commit

Permalink
Merge pull request #77 from AlexKnauth/transform
Browse files Browse the repository at this point in the history
change argument order of lens-transfrom, closes #72
  • Loading branch information
jackfirth committed Jul 8, 2015
2 parents eb8da3b + 83d250c commit a36b350
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 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 "0.3")
(define version "0.4")


(define deps
Expand Down
6 changes: 3 additions & 3 deletions lens/base/transform.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
lens-transform*)


(define (lens-transform lens f v)
(define (lens-transform lens v f)
(let-lens (view setter) lens v
(setter (f view))))

(module+ test
(define (set-first l v)
(list* v (rest l)))
(define first-lens (make-lens first set-first))
(check-equal? (lens-transform first-lens number->string '(1 2 3))
(check-equal? (lens-transform first-lens '(1 2 3) number->string)
'("1" 2 3)))


Expand All @@ -30,7 +30,7 @@
lenses/fs))
(for/fold ([v v]) ([lens/f (in-slice 2 lenses/fs)])
(match-define (list lens f) lens/f)
(lens-transform lens f v)))
(lens-transform lens v f)))

(module+ test
(define (set-second l v)
Expand Down
6 changes: 3 additions & 3 deletions lens/base/transform.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
@title{Transforming Values With Lenses}

@defproc[(lens-transform [lens lens?]
[transformer (-> view/c view/c)]
[target target/c])
[target target/c]
[transformer (-> view/c view/c)])
target/c]{
Transforms the view of @racket[target] through the given @racket[lens]
with the @racket[transformer] function. Equivalent to getting the
Expand All @@ -20,7 +20,7 @@
to the return value of calling @racket[transformer] with the old
view.
@lenses-examples[
(lens-transform first-lens number->string '(1 2 3))
(lens-transform first-lens '(1 2 3) number->string)
]}

@defproc[(lens-transform* [target target/c] [lens lens?] [transformer (-> view/c view/c)] ... ...)
Expand Down
2 changes: 1 addition & 1 deletion lens/list/cadr-etc.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@
ddaa ddad ddda dddd)

(module+ test
(check-equal? (lens-transform cdaddr-lens list->vector '(9 8 (6 5 4 3 2 1) 7))
(check-equal? (lens-transform cdaddr-lens '(9 8 (6 5 4 3 2 1) 7) list->vector)
'(9 8 (6 . #(5 4 3 2 1)) 7)))
2 changes: 1 addition & 1 deletion lens/list/car-cdr.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
@lenses-examples[
(cdaddr '(9 8 (6 5 4 3 2 1) 7))
(lens-view cdaddr-lens '(9 8 (6 5 4 3 2 1) 7))
(lens-transform cdaddr-lens list->vector '(9 8 (6 5 4 3 2 1) 7))
(lens-transform cdaddr-lens '(9 8 (6 5 4 3 2 1) 7) list->vector)
]}

0 comments on commit a36b350

Please sign in to comment.