[racket] formlet-fill

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Nov 22 07:50:30 EST 2011

On Mon, Nov 21, 2011 at 12:00 PM, Jordan Schatz <jordan at noionlabs.com>wrote:

> On Mon, Nov 21, 2011 at 06:32:18AM -0700, Jay McCarthy wrote:
> > I can imagine implementing something like...
> >
> > (define record-formlet
> >             (formlet
> >              ;; Define the input format
> >              ([name (hash-ref this 'name)]
> >               [company (hash-ref this 'company)]
> >               [address (hash-ref this 'company)]
> >               [city (hash-ref this 'city)]
> >               [state (hash-ref this 'state)]
> >               [zip (hash-ref this 'zip)])
> >              ;; Define the display format / input mapping
> >              (#%# ,{(to-string (required (text-input))) . <=> . name}
> >                   ,{(to-string (required (text-input))) . <=> . company}
> >                   ,{(to-string (required (text-input))) . <=> . address}
> >                   ,{(to-string (required (text-input))) . <=> . city}
> >                   ,{(to-string (required (text-input))) . <=> . state}
> >                   ,{(to-string (required (text-input))) . <=> . zip})
> >              ;; Define the output format
> >              (values name company address city state zip)))
> >
> > Does that seem more palatable?
> Yes... In my usage I think I would always be giving it a hashtable, and
> getting a hashtable back, and the names on the right hand side of the
> formlet would correspond to the keys in the input and output hashtable.
>
> I see that it might not be generally useful and probably doesn't belong
> in web-server/formlets
>

I'll put on my list of things to investigate.


>
> > Your version that breaks mainly breaks because you are mutating the
> > record and recomputing the formlet, rather than saving the formlet in
> > the continuation for both the display and the processing.
> So is this http://noionlabs.com/formlets/save-formlet.rkt the general
> pattern of how others are writing their formlets? (using a maker /
> generator function to create a form with initial values, and keeping it
> in a variable for the processing step?)
>

Basically, although I would not expect people to use mutation like that
when binding will do:

https://gist.github.com/1385592


> Are there any open sourced web apps built in racket where I could
> observer how people are using racket's features?
>

Here's the last one I wrote

https://github.com/jeapostrophe/m8b

Jay


-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111122/e5e0407d/attachment.html>

Posted on the users mailing list.