[racket] Functional Updates for Structs

From: Danny Gratzer (danny.gratzer at gmail.com)
Date: Tue Aug 27 11:33:44 EDT 2013

It's part of a DSL I'm writing, the idea being a user gives an accessor to
some struct, a function to transform the accessed data, an updater to store
the transformed data into another struct. I've nicknamed these source,
pipe, and sink procedures respectively.

The end goal is a DSL that looks like

    (create-trans
        (wire source through pipe into sink) ...)

The context for this is robotics programming where source and sink structs
model input and the robot respectively. If anyone's familiar with LabView,
it's not entirely dissimilar.

I'm trying to make the DSL pleasant to use by avoiding mentioning anything
about type or field names, just accessors and updaters. So I have no
trouble extracting the needed data, but I there aren't any nice functional
updaters generated. I could write something like

    (create-trans output-type
       (wire source through pipe into field-name) ...)

which isn't too bad, but it's a bit asymmetric: source can be some
arbitrarily complex function but field-name is very limited. Probably I
should just suck it up and accept a bit of ugliness.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130827/767e6a77/attachment.html>

Posted on the users mailing list.