The first release
Restrict Language v0.0.1: values first, ownership clear
Restrict is a statically typed language designed for WebAssembly. It puts values before the operations that consume them, makes capability scopes explicit, checks affine ownership, and keeps abstraction resolvable at compile time. Version 0.0.1 is the first public line: the point from which the language, tools, and release contract move forward together.
Why put the value first?
Most languages spell a call by naming an operation and then placing its inputs inside it. Restrict uses Object–Subject–Verb order instead. The value being transformed appears first; the verb that receives it comes last.
fun increment: (value: Int32) -> Int32 = {
value + 1
}
fun double: (value: Int32) -> Int32 = {
value * 2
}
fun main: () -> Int32 = {
20
|> increment
|> double
}
The pipe is not alternate syntax layered on top of conventional calls.
It is one expression of the language's only calling order. A function
with several inputs uses (left, right) add; a function with
no inputs uses () now. Traditional
add(left, right) syntax is rejected.
This makes a program read in the same direction as its data flow. It also gives constructors and polymorphic operations a common shape: the value supplies context before the compiler resolves the operation.
Scope is a typed capability boundary
Restrict makes scoped inputs part of the language. A context
declares a typed environment, and a with expression supplies
that environment for one body block. The fields are neither global state
nor properties on a receiver object: they exist only inside that lexical
scope.
context Logging {
level: Int32
}
context RequestScope {
request_id: Int32
}
fun main: () -> Int32 = {
with Logging { level: 10 } {
with RequestScope { request_id: 32 } {
request_id + level
}
}
}
Scopes compose by nesting. The inner request scope can use the logging capability from its outer scope, while neither binding exists after its block ends. The compiler rejects unknown fields and type mismatches, and the context declaration supplies expected types when an expression—such as an empty collection—would otherwise be ambiguous. Configuration, policy, and capabilities can therefore be local and statically checked without being stored in a singleton or threaded through receiver state.
The built-in Arena uses the same with shape for a
memory boundary. Heap-backed values created in an explicit arena cannot
escape its body, while scalar summaries can. These v0.0.1 context scopes
are distinct from temporal affine types and lifetime relations, which
remain experimental rather than part of the release contract.
Ownership is part of the expression
Restrict bindings are affine: a value may be used zero or one time unless its type is Copy or the binding is explicitly mutable. This is less about forcing ceremony and more about making accidental duplication visible. Heap-backed values move; small scalar values remain reusable.
record Message {
text: String
}
fun read: (message: Message) -> String = {
message.text
}
fun main: () -> String = {
val message = Message { text: "ownership is visible" }
val text = message |> read;
text
// `message` cannot be consumed again here.
}
The compiler uses arenas rather than a tracing garbage collector. The current release resets the default arena at the executable boundary and rejects ownership mistakes before code generation. Temporal affine types remain experimental; v0.0.1 does not claim that unfinished resource model as stable language surface.
Inference should remove repetition, not intent
Restrict uses bidirectional type inference. Literal values, annotations, function parameters, return types, neighboring branches, and later uses can all contribute constraints. Generic functions and lambdas stay terse when the surrounding program already makes their meaning clear.
fun identity: <T>(value: T) -> T = {
value
}
fun main: () -> Int32 = {
with Arena { } {
val values = [1, 2, 3]
val shifted = values map {
it + 1
};
shifted
|> identity
|> list_count
}
}
The Arena scope keeps the source and mapped lists inside one
explicit allocation boundary; only the inferred Int32 count
leaves it. map opens a focused scope whose contextual
it binding is inferred from the collection element type. The
complete mapping clause then becomes the next pipeline value. Across
that flow, the literal, scoped lambda, generic map, generic
identity, and final
list_count all contribute type information. The compiler does
not silently guess unresolved generic types. Empty collections, absent
options, and one-sided results must eventually receive enough context from
an annotation or a real use. When inference cannot finish, the error asks
for a boundary instead of inventing a fallback.
Records describe products; enums describe choices
Records are constructed with named fields. Closed enums model a finite
set of alternatives, and their constructors use the same qualified OSV
order as other calls. Built-in Option and
Result follow that rule too.
enum DecodeError {
Empty
Invalid(String)
}
fun decode: (code: Int32) -> Result<Int32, DecodeError> = {
code == 0 then {
42 Result::Ok
} else {
"invalid code" DecodeError::Invalid Result::Err
}
}
fun explain: (result: Result<Int32, DecodeError>) -> String = {
result match {
Ok(value) => { "valid" }
Err(error) => {
error match {
DecodeError::Empty => { "empty" }
DecodeError::Invalid(message) => { message }
}
}
}
}
Construction is qualified because it creates a value in a type namespace:
42 Option::Some, () Option::None, or
message DecodeError::Invalid. Built-in match patterns stay
unqualified—Some(value), None,
Ok(value), and Err(error)—because the scrutinee
already determines the sum type. User-enum patterns remain qualified.
Forms express behavior without runtime objects
A form is a compile-time contract, not a value to instantiate. A concrete
record adopts the contract with takes, and a generic function
names the behavior it requires with an of bound. Resolution is
closed-world, static, and monomorphized; v0.0.1 has no vtables or dynamic
interface objects.
form Labelled {
fun label: (self: Self) -> String
}
record Badge {
text: String
}
Badge takes Labelled {
fun label: (self: Badge) -> String = {
self.text
}
}
fun read_label: <T of Labelled>(value: T) -> String = {
value |> label
}
Display uses this model. Scalars and strings have
compiler-provided adoptions; records can opt in explicitly. That lets
display, print, and println remain
polymorphic while every selected implementation is still known at compile
time.
The compiler is inspectable from source to Wasm
Restrict compiles through a lexer, parser, affine type checker, checked IR, and WebAssembly code generator. The browser playground runs that compiler locally and exposes program output alongside tokens, the AST, generated Wasm, and diagnostics. It is not a mock evaluator: the checked-in compiler bundle compiles and executes the same curated examples used by release tests.
The host boundary is deliberately narrower than the language. Programs can use records, strings, lists, options, results, enums, lambdas, and generics internally. The default public Wasm ABI exports concrete scalar parameters and results. An opt-in flat record ABI is experimental; WIT, the Component Model, and a stable generic or composite host ABI remain future work.
A language also needs a working path around the compiler
The release includes Warder for creating, checking, building, running, and testing projects. Direct local dependencies are locked with deterministic source hashes and compiled from staged snapshots. The compiler also exposes an LSP over stdio, and the repository ships documentation, examples, cross-platform binaries, checksums, and the browser playground from the same release contract.
This does not mean every distribution channel is ready. There is no public package registry, stable Homebrew formula, or VS Code Marketplace release yet. Version 0.0.1 is a usable foundation, not a claim that the language is finished.
The starting line
Earlier notes described intermediate compiler states. This article replaces that chronology with one coherent baseline. From v0.0.1 onward, changes can be explained relative to a tagged language, a tested toolchain, and a public statement of what is intentionally still outside the contract.
The next work should deepen the model rather than blur it: stronger resource lifetimes, a designed component boundary, richer but still static forms, and better tooling around packages and editors. The principle remains the same—put the value first, make ownership clear, and keep the generated program understandable end to end.