► |  | Web Server: PLT HTTP Server

1 | Running the Web Server
2 | Writing Servlets
3 | Extending the Web Server
4 | Troubleshooting and Tips
5 | Acknowledgements
| Index

► | 2 | Writing Servlets

2.1 | Defining a Servlet
2.2 | APIs
2.3 | Common Contracts
2.4 | HTTP
2.5 | Web Interaction
2.6 | Stateless Web Interaction
2.7 | Web Cells
2.8 | File Boxes
2.9 | Stateless Web Parameters
2.10 | Formlets
2.11 | Templates
2.12 | Continuation Managers

▼ | 2.10 | Formlets

2.10.1 | Basic Formlet Usage
2.10.2 | Syntactic Shorthand
2.10.3 | Functional Usage
2.10.4 | Predefined Formlets
2.10.5 | Utilities

On this page:

xexpr-forest/ c
formlet/ c
pure
cross
cross*
xml-forest
xml
text
tag-xexpr
formlet-display
formlet-process

Version: 4.1.4
top← prev up next →

##### 2.10.3`` Functional Usage

(require web-server/formlets/lib)

The syntactic shorthand abbreviates the construction of formlets with the following library. These combinators may be used directly to construct low-level formlets, such as those for new INPUT element types. Refer to Predefined Formlets for example low-level formlets using these combinators.

xexpr-forest/c : contract?

Equivalent to (listof xexpr?)

(formlet/c content) → contract?
content : any/c

Equivalent to (-> integer? (values xexpr-forest/c (-> (listof binding?) (coerce-contract 'formlet/c content)) integer?)).

A formlet’s internal representation is a function from an initial input number to an X-expression forest rendering, a processing function, and the next allowable input number.

(pure value) → (formlet/c any/c)
value : any/c

Constructs a formlet that has no rendering and always returns value in the processing stage.

(cross f g) → (formlet/c any/c)
f : (formlet/c (any/c . -> . any/c))
g : (formlet/c any/c)

Constructs a formlet with a rendering equal to the concatenation of the renderings of formlets f and g; a processing stage that applies g’s processing result to f’s processing result.

(cross* f g ...) → (formlet/c any/c)
f : (formlet/c (() () #:rest (listof any/c) . ->* . any/c))
g : (formlet/c any/c)

Equivalent to cross lifted to many arguments.

(xml-forest r) → (formlet/c procedure?)
r : xexpr-forest/c

Constructs a formlet with the rendering r and the identity procedure as the processing step.

(xml r) → (formlet/c procedure?)
r : xexpr?

Equivalent to (xml-forest (list r)).

(text r) → (formlet/c procedure?)
r : string?

Equivalent to (xml r).

(tag-xexpr tag attrs inner) → (formlet/c any/c)
tag : symbol?
attrs : (listof (list/c symbol? string?))
inner : (formlet/c any/c)

Constructs a formlet with the rendering (list (list* tag attrs inner-rendering)) where inner-rendering is the rendering of inner and the processing stage identical to inner.

(formlet-display f) → xexpr-forest/c
f : (formlet/c any/c)

Renders f.

(formlet-process f r) → any/c
f : (formlet/c any/c)
r : request?

Runs the processing stage of f on the bindings in r.

top← prev up next →