Staged Dependent Types
Types, regions, effect rows, and tables are first-class compile-time values solved via Normalization by Evaluation and erased before codegen.
Tess is a statically typed, self-hosted systems language with staged dependent types, capability-based memory regions, orphan-free interfaces, and cost-stratified algebraic effects—compiling directly to native x86_64/aarch64, WebAssembly, and SPIR-V 1.6 with no GC and no borrow checker.
State = /ctrl/State
sumSlice = fun $R: Region, xs: ptr R slice I32 -> I32
with [/mem/Read R, State I32].
i = local USize 0
while i < xs.len.
(State I32).put ((State I32).get () + xs[i])
i <- i + 1
(State I32).get ()
public main = fun () -> () with /ctrl/BuiltinEffects.
:'Buf do
scores: array 3 I32 = local [10, 20, 12]
acc = local I32 0
defer /io/stdout.println "done"
total = do sumSlice scores[0 ..< 3] where
(State I32).get () => acc
(State I32).put v => acc <- v
/io/stdout.println (/str/concat "total = " (/str/toString total))
Expressive compile-time abstractions that erase cleanly down to predictable runtime representations.
Types, regions, effect rows, and tables are first-class compile-time values solved via Normalization by Evaluation and erased before codegen.
No aliasing exclusivity: multiple pointers and slices can alias freely inside static regions governed by /mem/Read, /mem/Write, and scoped :'Foo blocks.
Capability effects erase completely, unwinds lower to native setjmp/longjmp or Wasm EH, tail-resumptive handlers pass evidence directly, and yield/resume uses WasmFX or native fibers.
Orphan-free lexical instance resolution via use, where, and newtype ... with, paired with composable first-class patt extractors.
Shared Runtime MIR optimizer lowers to native x86_64/aarch64 (QBE 1.3 or C11), freestanding multi-memory Wasm32, and SPIR-V 1.6 Vulkan/WebGPU shaders.
Zero-dependency compiler, pure-Tess build system (build.tess), formatter (tess fmt), Wasmtime REPL, and built-in LSP 3.17 server (tess-lsp).
Every snippet below is valid Tess—open any tab directly in the browser Playground to run and inspect IR.
Yield = /ctrl/Yield
public cleanup_log: I32 = shared 0
stream = fun () -> I32 with [Yield I32, /mem/ReadWrite 'Static].
defer cleanup_log <- cleanup_log + 1
if (yield (Yield I32).emit 10).
yield (Yield I32).emit 32
0
else
1
public main = fun () -> I32 with /ctrl/BuiltinEffects.
cleanup_log <- 0
total = do stream () where
(Yield I32).emit v resume => if v < 30. v + resume true else v
/io/stdout.println (/str/concat "total = " (/str/toString total))
/io/stdout.println (/str/concat "cleanups = " (/str/toString cleanup_log))
total + cleanup_log
Even = patt x: I32 -> opt I32.
if (x / 2) * 2 == x. x / 2 else null
DivBy = fun d: I32 -> (patt I32 -> I32).
patt x: I32 -> opt I32.
if (x / d) * d == x. x / d else null
public classify = fun n: I32 -> I32.
match n.
Even (DivBy 3 q) => q * 10
Even h => h
_ => -1
public main = fun () -> I32 with /ctrl/BuiltinEffects.
res = classify 18
/io/stdout.println (/str/concat "classify(18) = " (/str/toString res))
res
Meters = newtype F32 with
scale = fun self: Self, k: F32 -> Self.
Self (F32 self * k)
instance /ops/Add Self.
add = fun a: Self, b: Self -> Self.
Self (F32 a + F32 b)
addTwice = fun x: (S: impl /ops/Add) -> (/ops/Add S).Result
with [...(/ops/Add S).Effects].
x + x
public main = fun () -> () with /ctrl/BuiltinEffects.
dist = (Meters 12.5).scale 2.0
doubled = addTwice dist
/io/stdout.println (/str/concat "meters = " (/str/toString (F32 doubled)))
Uniforms = struct [/attr/std140] {
.time: F32
.pad: F32
.resolution: vec 2 F32
}
uniforms = shared 'Uniform [/attr/binding 0 0] Uniforms
frag_coord = shared 'Input [/attr/builtin .fragCoord] (vec 4 F32)
out_color = shared 'Output [/attr/location 0] (vec 4 F32)
public fragMain = fun () -> ()
with [/attr/stage .fragment, /mem/Read 'Uniform, /mem/Read 'Input, /mem/Write 'Output].
u: Uniforms = uniforms
fc: vec 4 F32 = frag_coord
uv = /gpu/vec2 (fc[0] / u.resolution[0]) (fc[1] / u.resolution[1])
c = /math/sin (uv[0] * F32 6.28318 + u.time) * F32 0.5 + F32 0.5
out_color <- /gpu/vec4 c uv[1] (F32 0.5) (F32 1.0)
Bootstrap the self-hosted compiler from its portable C11 Stage 0 seed with just cc, ar, and xz.
mkdir -p tess-out/bin
xz -dc ../tess-stage0/tess0.c.xz | ${CC:-cc} -std=c11 -O1 -x c - -lm -o tess-out/bin/tess-stage0
./tess-out/bin/tess-stage0 build
./tess-out/bin/tess build
./tess-out/bin/tess run --target=native examples/basics/hello.tess
./tess-out/bin/tess build --target=wasm32 --emit-abi examples/basics/interface.tess
./tess-out/bin/tess build --target=spirv32 --validate examples/shaders/sdf_raymarch.tess
./tess-out/bin/tess test --target=native --manifest package.tess