Swarm typing judgments [000V]
- November 3, 2025
Swarm has two basic typing judgments: a top-level judgment that assigns capability-annotated polytypes, and a basic judgment that assigns monotypes to terms and collects the capabilities needed to evaluate them.
Definition Top-level typing judgment [001M]
- November 14, 2025
The top-level typing judgment is of the form \Gamma \vdash t : \sigma which simply says that term t has polytype \sigma in context \Gamma . Here \Gamma is a type context associating variables with their types. The polytype \sigma quantifies over type and capability variables, and contains a set of capbilities needed to evaluate the term t.
Definition Monomorphic typing judgment [001O]
- November 14, 2025
The basic typing judgment for the Swarm language has the form \Gamma \vdash t : \tau \;[\Delta ] where \Gamma is a type context, t is a term, \tau is a monotype (which could contain type variables), and \Delta is a capability set expression. This should intuitively be read as saying that t has type \tau in context \Gamma , and can be evaluated given capabilities \Delta . In this judgment \Gamma and t are considered inputs, \Delta is considered an output, and \tau can be either an input or an output depending on whether we are in checking or inference mode. In practice, the typing rules are implemented in an explicitly bidirectional style, but are presented here as undirected rules for simplicity.
Remark [001Q]
- November 14, 2025
Note that the basic typing judgment only says something about the capabilities required to evaluate t. Further use of the resulting value may require additional capabilities: for example, evaluating the application of t to an argument, if it is a function; or executing t, if it is a command. As a rule, the capabilities needed for such uses beyond evaluation are recorded in the type \tau .
Remark [001R]
- November 14, 2025
At the level of the basic typing judgment, the capability set \Delta is not part of the monotype \tau , but rather part of the judgment. The reason is that we want to maintain the invariant that polytypes only record a single, top-level capability set, and other capability sets are recorded at appropriate points within the type (e.g. as annotations on function arrows) rather than being sprinkled on every single subterm of the type.
Subtyping [00GV]
- June 11, 2026
We have a mild form of subtyping, in that we can always weaken a judgment by adding more capabilities:
Generalization and instantiation [001P]
- November 14, 2025
XXX add capability set variables and describe. Where can the different kinds of variables occur? (Hence, where do we need to apply substitutions?)