<div>I&#39;d like to create a Lens structure which is a procedure structure.  The structures exec procedure would be a case-lambda parameterized by A, B.</div><div><br></div><div>(define-struct/exec:  (A B) Lens ([getter : (A -&gt; B)][setter : (B A -&gt; A)]) [fn : (case-&gt; (A -&gt; B) (B A -&gt; A))])</div>
<div><br></div><div>where fn would be the getter and setter detemined by arity at the call site.</div><div><br></div><div>Looks like currently a define-struct/exec: cannot be parameterized.  Is this something that might be available down the road?</div>
<div><br></div><div>The goal is to say</div><div><br></div><div>(int-lens 3 (int-lens 2))</div><div><br></div><div>as opposed to say</div><div><br></div><div>(set int-lens 3 (get int-lens 2))</div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div>;; Below is current effort.  Want to do a define-struct/exec</div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div><div><br></div><div>(struct: (A B) Lens ([getter : (A -&gt; B)]</div>
<div>                     [setter : (B A -&gt; A)]))</div><div><br></div><div>(: get (All (A B) (Lens A B) A -&gt; B))</div><div>(define (get lens a)</div><div>  ((Lens-getter lens) a))</div><div><br></div><div>(: set (All (A B) (Lens A B) B A -&gt; A))</div>
<div>(define (set lens b a)</div><div>  ((Lens-setter lens) b a))</div><div><br></div><div>(: mod (All (A B) (Lens A B) (B -&gt; B) A -&gt; A))</div><div>(define (mod lens f a)</div><div>  (set lens (f (get lens a)) a))</div>
<div><br></div><div>(: and-then (All (A B C) (Lens A B) (Lens B C) -&gt; (Lens A C)))</div><div>(define (and-then lens-ab lens-bc)</div><div>  (Lens (ė: ((a : A))</div><div>          ((Lens-getter lens-bc) ((Lens-getter lens-ab) a)))</div>
<div>        (ė: ((c : C) (a : A))</div><div>          (mod lens-ab (ė: ((b : B)) ((Lens-setter lens-bc) c b)) a))))</div><div>          </div><div>(: compose (All (A B C) (Lens B C) (Lens A B) -&gt; (Lens A C)))</div><div>
(define (compose lens-ab lens-ca)</div><div>  (and-then lens-ca lens-ab))</div><div>              </div>