2 Web Field Specifications🔗ℹ

RacketUI generates a user interface based on an annotated specification of the types of data that the underlying function consumes and produces. The types of data that RacketUI supports are given by the web specs below. These are intended to correspond to the types of data used in How to Design Programs.

For the purposes of generating a user-friendly interface, specifications are annotated with text informally describing their purpose or interpretation in the context of the program.

  • An annotated web field specification, which we call a labeled spec, is a pair

    syntax

    [label spec]

    where label is a string and spec is a web spec.

  • A web spec (web field specification) is one of

    syntax

    (constant x)

    where x is any value

    syntax

    boolean

    syntax

    number

    syntax

    symbol

    syntax

    string

    syntax

    string+

    for non-empty strings

    syntax

    image

    syntax

    filename

    for functions that expect the name of an input file whose content will be read, or that produce the name of a generated output file

    syntax

    (structure constr lab-spec ...+)

    where constr is a structure constructor and lab-spec are one or more labeled specs corresponding to the types expected for the fields of the structure

    syntax

    (oneof lab-spec ...+)

    where lab-spec are one or more labeled specs corresponding to an itemization (union) of specifications

    syntax

    (listof lab-spec)

    or, for non-empty lists,

    syntax

    (listof+ lab-spec)

    where lab-spec is a labeled spec describing the type of elements in the list

    syntax

    (function purpose (proc lab-spec ...+ -> lab-spec))

    where purpose is a string, proc is the name of a procedure, and lab-spec are labeled specs. This form represents a specification for the given function (proc), consuming one or more parameters whose specifications precede ->, and producing data that meets the right-most specification.

    At the moment, only the outermost form of a web spec should be a function, and it is what should be provided to web-launch (see Starting a Web Application).

It is possible to define a name for specifications that occur repeatedly:

syntax

(define/web id spec)

After this, id can be used in any context where a web spec is expected.