Hi all,

I wonder what the best way is to integrate formlets into typed programs. I 
simply `require/typed` formlet-display  as type (-> Any Any), which is not 
illuminating, but the display part is rarely the problem.

formlet-process is tricky. The earliest point at which I 'know' the type of 
processing a given formlet is directly when formlet-process is called, so 
that's the best time to start typing to get most of the types checked. 
Ideally I would do something like:

(define s-formlet 
  (formlet (div (label "Enter a string:")
                ,{=> input-string a-string})
           [a-string : String]))

and be done with it. Of course I cannot type it this way. One solution is 
to define

(define (s-formlet-process a-formlet a-request)
  (formlet-process a-formlet a-request))

provide it, and then require it with the correct type in the next file. 
That's sort of what I am doing right now, but it requires quite a bit of 
boiler-plate everywhere. The problem is that I don't see how I would even 
start typing s-formlet itself, since (I think) it is a macro that changes 
how formlet-process deals with it, so I don't even know where to start 
typing any of it. When I expand formlet-process in the macro stepper, it 
turns into the application of some idY11 with something lifted (none of 
which I understand), and I don't see how I would make the type of 
(formlet-process a-formlet ...) dependent on which formlet it is that I am 

One idea I had is to define my-formlet-process which takes the name as a 
symbol, rather than as an id, and uses different type signatures depending 
on the symbol, using case->:

#lang racket

(define (my-formlet-process name req)
  (cond [(eq? name 'integer-formlet) (formlet-process integer-formlet req)]
            [(eq? name 'string-formlet) (formlet-process string-formlet 

and then require/typed this via (case-> (-> 'integer-formlet Integer) (-> 
'string-formlet String)). This cuts down on having to define all the 
intermediaries, and puts all the types for formlets in one place. It still 
feels more tedious than it has to be, but it is probably not trivial to 
make this much easier.

Any thoughts on if the above is an OK if not best practice, or ideas for 
improvements? I guess using types with some rather sophisticated macros may 
in general be a little tricky - any pointers to other places on how to do 
this and how to figure out how to type it are appreciated.


You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to