| permalink | /04-type-system.html |
|---|---|
| title | Type System |
This page summarizes normative FTS behavior from FACET v2.1.3.
stringintfloatboolnullany
Constraint violations:
- type mismatch →
F451 - invalid constraint/placement/unsupported construct →
F452
struct { field: T, ... }list<T>map<string, T>- union:
T1 | T2 | ...
Optional fields are expressed as T | null.
imagewith constraints:format ∈ {png,jpeg,webp},max_dimaudiowith constraints:format ∈ {mp3,wav,ogg},max_durationembedding<size=N>whereN > 0
T1 assignable to T2 iff one of:
T2 == any- same primitive + constraints satisfied
- union target contains assignable member
- list/map element assignability
- struct target required fields exist and are assignable
@var_types is an ordered singleton map from variable name to FTS expression.
@var_types
username: "string"
age: "int"
score: "float"
status: "string | null"
@vars
username: "alice"
age: 30
score: 97.5
status: null
If a declared type exists, computed value must satisfy it.
@vars
query: @input(type="string") |> trim()
n: @input(type="int", default=3)
typeis required and must parse as FTS type.- supplied/defaulted runtime value must satisfy
type, elseF453.
Each pipeline step must accept previous step output type.
@vars
raw: " HELLO "
clean: $raw |> trim() |> lowercase()
Invalid:
@vars
bad: 42 |> trim()
This must fail with F451 (wrong input type for lens).
@interface signatures must map to JSON Schema (Appendix D):
- primitive mappings (
string/int/float/bool/null/any) - struct → object with
required - list/map/union mapping
embedding<size=N>mapped to fixed-length numeric array
Unmappable type usage must raise F452.