Enums
An enum declares a reusable, closed set of allowed values. Enum declarations
sit between version and the input block. Variants are homogeneous — all text,
all integer, or all number. The base type is inferred from the variants, or you
can annotate it explicitly with : text, : integer, or : number.
enum SparseMode = None | Bm25 | External
enum EmbeddingType = Float | Binary | Float16 | BFloat16 | Int8
enum Dimensions = 128 | 256 | 512 | 1024 | 2048
enum Threshold = 0.25 | 0.35 | 0.5
-- Explicit base annotations:
enum HttpStatus : integer = 200 | 201 | 400 | 403 | 404 | 500
enum ApiVersion : text = "v1" | "v2" | "v3"Variant forms:
- bare identifiers → a text enum (
None,Bm25,Float16). - quoted strings → a text enum (
"v1","v2"). - integer literals → an integer enum (
128,256). - float literals → a number enum (
0.25,0.5).
Mixing variant kinds in one enum is rejected. Declaring : number with all-int
variants is allowed (they widen).
Using an enum
Reference the enum name as a field type. The compiler validates that the default (and any supplied value) is one of the variants.
enum SparseMode = None | Bm25 | External
enum EmbeddingType = Float | Binary | Float16 | BFloat16 | Int8
enum Dimensions = 128 | 256 | 512 | 1024 | 2048
enum ApiVersion : text = "v1" | "v2" | "v3"
input
sparse_mode : SparseMode = None
embedding_type : EmbeddingType = Float
dimensions : Dimensions = 1024
api_version : ApiVersion = "v1"If you write a default that is not a variant, you get a compile error naming the
allowed set — for example, dimensions : Dimensions = 300 would be rejected with
“not a variant of enum ‘Dimensions’ (allowed: 128, 256, 512, 1024, 2048)”. Enums
are great for wiring model names, encoding formats, and routing modes into a
script’s contract without typos.
Next: validation rules in Constraints.