Skip to content

Conversation

@AlexKnauth
Copy link
Collaborator

@AlexKnauth AlexKnauth commented Nov 25, 2017

This pull request adds isomorphism-cond, isomorphism-join, lazy-isomorphism, and rec-isomorphism.

TODO: Add docs.

Examples:

(define (map-iso item-iso)
  (rec-isomorphism the-map-iso
    (isomorphism-cond
      [empty?  identity-lens  empty?]
      [cons?
       (isomorphism-join
         cons
         cons
         [first  item-iso     first]
         [rest   the-map-iso  rest])
       cons?])))

(define (tree-map-iso a? item-iso b?)
  (rec-isomorphism the-tree-iso
    (isomorphism-cond
      [a? item-iso b?]
      [list? (map-iso the-tree-iso) list?])))
 
;; Converts between a base 4 number represented as a list of digits
;; (least significant first, most significant last) and a number.
(define base4->number-iso
  (lazy-isomorphism
   (isomorphism-cond
     [empty?  (const-isomorphism '() 0)  zero?]
     [cons?
      (isomorphism-join
        cons
        (λ (r q) (+ (* 4 q) r))
        [first  identity-isomorphism  (curryr remainder 4)]
        [rest   base4->number-iso     (curryr quotient 4)])
      positive?])))

@ghost ghost assigned AlexKnauth Nov 25, 2017
@ghost ghost added the in progress label Nov 25, 2017
@codecov
Copy link

codecov bot commented Nov 25, 2017

Codecov Report

Merging #300 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #300      +/-   ##
==========================================
+ Coverage   97.98%   98.06%   +0.07%     
==========================================
  Files         100      101       +1     
  Lines        1736     1806      +70     
==========================================
+ Hits         1701     1771      +70     
  Misses         35       35
Impacted Files Coverage Δ
lens-common/lens/private/isomorphism/compound.rkt 100% <100%> (ø) ⬆️
lens-common/lens/private/isomorphism/lazy.rkt 100% <100%> (ø)
lens-data/lens/private/vector/ref.rkt 100% <0%> (ø) ⬆️
lens-data/lens/private/string/string.rkt 100% <0%> (ø) ⬆️
lens-data/lens/private/syntax/syntax.rkt 100% <0%> (ø) ⬆️
lens-common/lens/private/compound/if.rkt 90.9% <0%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1caa237...8f404ff. Read the comment docs.

@jackfirth jackfirth self-requested a review November 28, 2017 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants