From 734bfbaa6925a3390ff35eb98468adf6f3b753d3 Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Tue, 14 Jul 2015 23:48:31 -0400 Subject: [PATCH] rename list-compound-lens and hash-compound-lens to lens-join/... --- unstable/lens/{compound.rkt => join.rkt} | 24 ++++++++++---------- unstable/lens/{compound.scrbl => join.scrbl} | 20 ++++++++-------- unstable/lens/list.rkt | 4 ++-- unstable/lens/main.rkt | 4 ++-- unstable/lens/main.scrbl | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) rename unstable/lens/{compound.rkt => join.rkt} (73%) rename unstable/lens/{compound.scrbl => join.scrbl} (62%) diff --git a/unstable/lens/compound.rkt b/unstable/lens/join.rkt similarity index 73% rename from unstable/lens/compound.rkt rename to unstable/lens/join.rkt index 61c1743..39097c9 100644 --- a/unstable/lens/compound.rkt +++ b/unstable/lens/join.rkt @@ -10,14 +10,14 @@ (provide (contract-out - [compound-list-lens (->* () #:rest (listof lens?) lens?)] - [compound-hash-lens (->* () #:rest (listof2 any/c lens?) lens?)])) + [lens-join/list (->* () #:rest (listof lens?) lens?)] + [lens-join/hash (->* () #:rest (listof2 any/c lens?) lens?)])) (define (zip xs ys) (append-map list xs ys)) -(define (compound-list-lens . lenses) +(define (lens-join/list . lenses) (define (get target) (apply lens-view/list target lenses)) (define (set target new-views) @@ -27,16 +27,16 @@ (module+ test (define first-third-fifth-lens - (compound-list-lens first-lens - third-lens - fifth-lens)) + (lens-join/list first-lens + third-lens + fifth-lens)) (check-equal? (lens-view first-third-fifth-lens '(a b c d e f)) '(a c e)) (check-equal? (lens-set first-third-fifth-lens '(a b c d e f) '(1 2 3)) '(1 b 2 d 3 f))) (define first-first-lens - (compound-list-lens first-lens - first-lens)) + (lens-join/list first-lens + first-lens)) (define (value-list->hash keys vs) @@ -55,9 +55,9 @@ '((a b c) (1 2 3) (FOO BAR BAZ)))) -(define (compound-hash-lens . keys/lenses) +(define (lens-join/hash . keys/lenses) (match-define (list keys lenses) (split-slice 2 keys/lenses)) - (define list-lens (apply compound-list-lens lenses)) + (define list-lens (apply lens-join/list lenses)) (define (get target) (value-list->hash keys (lens-view list-lens target))) (define (set target new-view-hash) @@ -65,8 +65,8 @@ (make-lens get set)) (module+ test - (define a-b-lens (compound-hash-lens 'b third-lens - 'a first-lens)) + (define a-b-lens (lens-join/hash 'b third-lens + 'a first-lens)) (check-equal? (lens-view a-b-lens '(1 2 3)) (hash 'a 1 'b 3)) (check-equal? (lens-set a-b-lens '(1 2 3) (hash 'a 100 'b 200)) diff --git a/unstable/lens/compound.scrbl b/unstable/lens/join.scrbl similarity index 62% rename from unstable/lens/compound.scrbl rename to unstable/lens/join.scrbl index f2f013c..9a7d2f4 100644 --- a/unstable/lens/compound.scrbl +++ b/unstable/lens/join.scrbl @@ -3,11 +3,11 @@ @(require lens/doc-util/main) -@title{Compound Lenses} +@title{Joining Lenses} -@defmodule[unstable/lens/compound] +@defmodule[unstable/lens/join] -@defproc[(compound-list-lens [lens lens?] ...) lens?]{ +@defproc[(lens-join/list [lens lens?] ...) lens?]{ Constructs a lens that combines the view of each @racket[lens] into a list of views. This lens can be used to view and set a list of values in a single @@ -15,22 +15,22 @@ setting the later lenses override the earlier ones. @lenses-unstable-examples[ (define first-third-fifth-lens - (compound-list-lens first-lens - third-lens - fifth-lens)) + (lens-join/list first-lens + third-lens + fifth-lens)) (lens-view first-third-fifth-lens '(a b c d e f)) (lens-set first-third-fifth-lens '(a b c d e f) '(1 2 3)) ]} -@defproc[(compound-hash-lens [key any/c] [lens lens?] ... ...) lens?]{ +@defproc[(lens-join/hash [key any/c] [lens lens?] ... ...) lens?]{ Constructs a lens that combines the view of each @racket[lens] into a hash of views with @racket[key]s - as the hash keys. In the same manner as @racket[compound-list-lens], + as the hash keys. In the same manner as @racket[lens-join/list], if lenses share views later lenses take precedence when setting. @lenses-unstable-examples[ - (define a-b-lens (compound-hash-lens 'a first-lens - 'b third-lens)) + (define a-b-lens (lens-join/hash 'a first-lens + 'b third-lens)) (lens-view a-b-lens '(1 2 3)) (lens-set a-b-lens '(1 2 3) (hash 'a 100 'b 200)) ]} diff --git a/unstable/lens/list.rkt b/unstable/lens/list.rkt index bce7392..54eb9a3 100644 --- a/unstable/lens/list.rkt +++ b/unstable/lens/list.rkt @@ -1,7 +1,7 @@ #lang racket (require lens - "compound.rkt") + "join.rkt") (module+ test (require rackunit)) @@ -21,7 +21,7 @@ (define (list-refs-lens . indices) - (apply compound-list-lens (map list-ref-lens indices))) + (apply lens-join/list (map list-ref-lens indices))) (module+ test (define 1-5-6-lens (list-refs-lens 1 5 6)) diff --git a/unstable/lens/main.rkt b/unstable/lens/main.rkt index 2aba118..9faf5c1 100644 --- a/unstable/lens/main.rkt +++ b/unstable/lens/main.rkt @@ -1,7 +1,7 @@ #lang racket (require "syntax.rkt" - "compound.rkt" + "join.rkt" "list.rkt" "hash.rkt" "view-set.rkt" @@ -11,7 +11,7 @@ ) (provide (all-from-out "syntax.rkt" - "compound.rkt" + "join.rkt" "list.rkt" "hash.rkt" "view-set.rkt" diff --git a/unstable/lens/main.scrbl b/unstable/lens/main.scrbl index fbc829a..3e84882 100644 --- a/unstable/lens/main.scrbl +++ b/unstable/lens/main.scrbl @@ -10,7 +10,7 @@ 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["join.scrbl"] @include-section["list.scrbl"] @include-section["hash.scrbl"] @include-section["syntax.scrbl"]