Skip to content

Language reference

Hyle describes lattice simulations with properties, presets, models, behaviors, phases and visuals. There is one supported source syntax; obsolete spellings are compile errors.

A project has exactly one main.hyle. It owns the mandatory world declaration and every execution phase. Phase order and the order of run statements are execution order. Importing a model makes its definitions available without implicitly scheduling its behaviors.

Other .hyle files may contain properties, presets, models, behaviors, visuals, visual bindings, inputs, constants, functions, structs, enums, type aliases, neighborhoods and published imports. These declarations may appear in any order. A preset may precede its property; a function may precede a helper it calls. Declarations share one project scope, regardless of file paths. Duplicate names and cyclic pure definitions are errors.

main.hyle
materials/water.hyle
materials/fire.hyle
presets/cold.hyle
math/thermal.hyle
initial.hyleworld

Definitions in local files need no imports between them. Published parts use exact @author/Name#revision coordinates. File-scoped namespaces and physics import aliases are not currently supported.

property Thermal {
temperature: Float [0.0, 1.0] = 0.25;
}
input ambient: Float [0.0, 1.0] = 0.2;
const cooling_rate: Float = 0.01;

Scalar types are Float, Int and Bool. Bounds are optional inclusive intervals with a required comma: [minimum, maximum]. Defaults use =. Source precision annotations are not supported; the solver profile chooses Float precision.

Constants are compile-time values, including structs, arrays and enums. They may reference other constants and pure functions. Integer overflow, division by zero and non-finite results are errors.

const cooling_rate: Float = 0.01;
fn cool(temperature: Float, ambient: Float, rate: Float) -> Float {
let difference = temperature - ambient;
return temperature - difference * rate;
}

Functions have explicit parameter and return types, immutable local let bindings, and a final return expression; or tail expression. Contracts are checked even for unused functions and unused parameters. Argument types must match; use 1.0 for a Float argument. Functions cannot implicitly read inputs, self, neighbors or simulation state; pass the required values as arguments. They may read constants and call other pure functions or scalar builtins. Recursion is rejected.

The compiler expands pure functions into scalar expressions before backend lowering. They add no runtime function-call requirement to CPU or GPU execution. Unused pure calculations may be eliminated. Expansion is bounded to prevent unbounded compilation of excessively large call graphs.

Field defaults and preset values accept closed expressions, constants and pure functions. Bounds remain scalar literals.

See Fixed-size value types for records, arrays, enums and aliases.

The source grammar is maintained in core/grammars/hyle.pest. The lexer vocabulary also generates the shared Studio/Atlas highlighter.

Hyle Astro