Back to AXON

Type System

AXON's 13 validated types ensure data integrity and catch errors before expensive LLM API calls

Built-in Types

Type Description Range/Format Example
u8 Unsigned 8-bit integer 0 to 255 42
i32 Signed 32-bit integer -2.1B to 2.1B -1000
f64 64-bit floating point Double precision 3.14159
bool Boolean true or false true
str UTF-8 string Any text "Hello"
iso8601 ISO 8601 date/time With validation 2025-01-15T10:30Z
uuid UUID identifier 39% smaller encoding 550e8400-e29b...
enum Categorical type Validated set "admin"

Type Modifiers

Nullable Types

Add ? to make any type nullable:

u8?     // Can be a number 0-255 or null
str?    // Can be a string or null
bool?   // Can be true, false, or null

Array Types

Add [] to create array types:

u8[]     // Array of unsigned 8-bit integers
str[]    // Array of strings
bool[]   // Array of booleans (automatically bit-packed!)

Combining Modifiers

You can combine modifiers for complex types:

u8?[]    // Array of nullable unsigned integers
str[]?   // Nullable array of strings

Type Validation Benefits

  • Catch errors early: Invalid data is rejected before costly API calls
  • Better compression: Types enable smarter compression algorithms
  • LLM optimization: Type hints help models understand data structure
  • Documentation: Types serve as inline documentation for your data

Example: E-commerce Data

import { encode, registerSchema, type Schema } from '@axon-format/core';

// Define schema with type annotations
const productSchema: Schema = {
  name: 'Product',
  fields: [
    { name: 'id', type: 'u8' },
    { name: 'sku', type: 'str' },
    { name: 'name', type: 'str' },
    { name: 'price', type: 'f64' },
    { name: 'inStock', type: 'bool' },
    { name: 'lastUpdated', type: 'iso8601' }
  ]
};

// Register schema globally
registerSchema(productSchema);

const product = {
  id: 1,
  sku: "WDG-001",
  name: "Premium Widget",
  price: 49.99,
  inStock: true,
  lastUpdated: "2025-01-15T10:30:00Z"
};

const encoded = encode(product, { schemas: [productSchema] });

Next: Learn how Compression Algorithms work to achieve massive token savings.