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.