Mesh type system: primitive types, structs, ADTs (sum types), generics, Option, Result, and type annotations.
Int — signed integer (maps to i64 at runtime)Float — double-precision floating pointBool — true / falseString — UTF-8 string (immutable)Unit — the type of expressions with no meaningful value (implicit return from void functions).to_string(), .to_int(), .to_float(), .to_bool() on primitive values.struct Name do field :: Type ... end.Name { field: value, ... } — all fields required, any order.user.name, user.age.end deriving(Json, Row, Display, Eq, Ord).struct Box<T> do value :: T end — type parameter in angle brackets.struct User do
name :: String
age :: Int
score :: Float
active :: Bool
end deriving(Json)
let u = User { name: "Alice", age: 30, score: 95.5, active: true }
println(u.name) # "Alice"
println("#{u.age}")
# Generic struct:
struct Box<T> do
value :: T
end deriving(Display, Eq)
let b1 = Box { value: 42 }
let bs = Box { value: "hello" }
println("#{b1}")
type Name do Variant1 / Variant2(T) / Variant3(A, B) end.Red, Green, Blue.Some(T), Ok(T), Err(E).let c = Red, let r = Ok(42), let e = Err("oops").case pattern matching — compiler enforces exhaustiveness.type Color do
Red
Green
Blue
end
let c = Blue
case c do
Red -> println("red")
Green -> println("green")
Blue -> println("blue")
end
# Built-in Result type (T!E shorthand):
fn validate(x :: Int) -> Int!String do
if x <= 0 do
return Err("must be positive")
end
Ok(x)
end
Option<T> represents a value that may or may not be present.Some(value) and None.case: case opt do Some(v) -> ... None -> ... end.? operator on Option: returns None early if the value is None.fn find_first(list :: List<Int>, target :: Int) -> Option<Int> do
List.find(list, fn(x) -> x == target end)
end
case find_first([1, 2, 3], 2) do
Some(v) -> println("found: #{v}")
None -> println("not found")
end
Result<T, E> represents success (Ok(T)) or failure (Err(E)).T!E means Result<T, E>.? operator: if the expression is Err(e), immediately return Err(e) from the current function. The function's return type must be T!SomeError.? composes fallible operations without nested case expressions.fn validate_positive(x :: Int) -> Int!String do
if x <= 0 do
return Err("must be positive")
end
Ok(x)
end
fn process(x :: Int) -> String!String do
let v = validate_positive(x)?
let w = validate_small(v)?
Ok("valid: #{w}")
end
case process(42) do
Ok(s) -> println(s)
Err(e) -> println("error: #{e}")
end
List<T> — ordered, resizable list. See skills/collections for full API.Map<K, V> — key-value store. Keys are typically String.Set<T> — unordered unique values.Queue<T> — FIFO queue.Range — integer range, used with for loops or Iter.from.[1, 2, 3].:: Type annotation to the let binding.