<div dir="ltr">Hello,<div><br></div><div>I'm writing some code to manipulate a few structs and in doing so have run into a rub. There doesn't seem to be a convenient way to do functional updates for structs.</div><div>
<br></div><div>Normally I'd use struct-copy, but I have neither the field nor the type name at compile time, currently I have a macro that looks like this</div><div><br></div><div> (wire some-struct-accessor ; source</div>
<div> some-proc ; pipe</div><div> (lambda (s v) (struct-copy type-name s [field-name v]))) ; sink</div><div><br></div><div>which just looks clunky when compared to the functional accessor. My research turned up a thread[1] from 2010 that proposed </div>
<div><br></div><div> (type-name/field struct val)</div><div><br></div><div>as an updater counterpart to </div><div><br></div><div> (type-name-field struct)</div><div><br></div><div>but that doesn't seem to have gone anywhere.</div>
<div><br></div><div>I figured I'd ask to see if I'm about to reinvent the wheel here before I just write some code to generate my update functions.</div><div><br></div><div>[1] <a href="http://lists.racket-lang.org/users/archive/2010-October/042390.html">http://lists.racket-lang.org/users/archive/2010-October/042390.html</a><br clear="all">
<div><div dir="ltr"><div><br></div>Cheers,<div>Danny Gratzer</div></div></div>
</div></div>