formawasm compiles a formalang Intermediate Representation (IR) module into a WebAssembly component — a .wasm binary that any standards-compliant runtime can execute.
formalang frontend ──► IrModule ──► formawasm ──► .wasm component ──► host runtime
formawasm is a backend: it doesn't parse .fv source files itself, and it doesn't run the resulting wasm. Both jobs belong to other libraries (formalang for parsing, wasmtime / wasmi / a browser engine for execution). formawasm only emits bytes.
The boundary between a component and its host is described in WIT — the small Interface Definition Language of the Component Model. formawasm generates the WIT file automatically from the public surface of each IR module; the host never hand-writes WIT.
Quickstart
Install the CLI:
Or pin to a specific version:
Compile a .fv source file:
# wrote id.wasm (… bytes) from id.fv
Inspect the generated WIT interface:
package formawasm:generated;
world component {
export id: func(x: s32) -> s32;
}
Run it directly with the wasmtime CLI — no host code required:
# 42
Or wire it into your Rust application:
use ;
use ;
let mut config = new;
config.wasm_component_model;
let engine = new?;
let bytes = read?;
let component = from_binary?;
let linker = new;
let mut store = new;
let instance = linker.instantiate?;
let id = instance.?;
let = id.call?;
assert_eq!;
Documentation
The full book lives at docs/ and is built with mdBook:
Highlights:
For users (embedding formawasm in a Rust application):
- Quickstart —
.fv→.wasmin 30 seconds - Using the Library —
WasmBackendfrom your own crate - Hosting a Component — running components under wasmtime
- Boundary Policy — what can cross the WIT boundary
- Type Mapping — formalang ↔ WIT
- Feature Coverage — what's supported, per IR variant
- Cargo Features —
wasm-opt,dwarf, validation - Troubleshooting — common errors
For contributors (extending the backend):
- Architecture — the seven-stage pipeline
- Crate Layout — what's in
src/ - Lowering — memory model, runtime helpers, per-IrExpr lowering
- Extending the Backend — adding IR variants, runtime helpers, layouts
- Testing — test conventions and milestone tests
- Contributing — code style, quality gates, microcommit cadence
Status
Phases 1 through 5 are closed. The backend produces a Component-Model artifact for every milestone — recursive functions (fib), structs + enums + methods (Counter / Action), arrays + ranges + for-loops (sieve of Eratosthenes), strings + optionals + dictionaries (greet), virtual dispatch (Greet trait across two impls), and host-provided externs (call_host(21) → 42 via host_double).
See CHANGELOG.md for the phase-by-phase history; the "Roadmap" section at the top captures what's left.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.