One package
@forma-language/forma contains the TypeScript engine, host, editor adapters, and language server. The engine runs in Node and in the browser.
Forma · programmable types for Lisp · pre-alpha
A programmable typechecker for Lisp, built for defining and checking domain languages.
Preludes define vocabulary and checks. Explore type inference, polymorphism and effects, or turn checked domain programs into data for your application to interpret. Try the live playground below ↓
A tiny custom prelude defines workflow, step and a closed set of actions.
release.prelude.lisp · excerpt
(type Action
(Union "process.test" "human.approve"))
(form (step name action)
:types {:name (Declares Step) :action Action}
:ir StepIR …)release.lisp
(workflow release (step verify "process.tset") (step approve "human.approve"))
The error is attached to the source you wrote, using the language’s checked contract.
Scripted stories, real recorded compiler results. Not live evaluation.
Edit this language live ↗(type Action (Union "process.test" "human.approve"))
(type StepIR {:kind "Step" :name Symbol :action Action})
(form (step name action)
:types {:name (Declares Step) :action Action}
:ir StepIR
{:kind "Step" :name name :action action})
(type WorkflowIR {:kind "Workflow" :name Symbol :steps (List StepIR)})
(form (workflow name step ...)
:types {:name (Declares Workflow) :step (List step)}
:ir WorkflowIR
{:kind "Workflow" :name name :steps step})(workflow release (step verify "process.test") (step approve "human.approve"))
{
"code": "elaborate/hole-type",
"severity": "error",
"message": "action must be one of \"process.test\", \"human.approve\"",
"phase": "elaborate",
"span": {
"sourceId": "release.lisp",
"startOffset": 33,
"endOffset": 47,
"startLine": 2,
"startColumn": 16,
"endLine": 2,
"endColumn": 30
},
"details": {
"form": "step",
"declaration": "release",
"hole": "action",
"expected": "Action",
"actual": "\"process.tset\"",
"candidates": [
"\"process.test\"",
"\"human.approve\""
]
},
"help": "Use a value matching the declared type of action."
}[
{
"kind": "Workflow",
"name": "release",
"steps": [
{
"kind": "Step",
"name": "verify",
"action": "process.test"
},
{
"kind": "Step",
"name": "approve",
"action": "human.approve"
}
]
}
]Forma checks language/type/effect contracts. Consumers own business meaning. Checked data does not prove interpreter agreement, legal correctness, authorization or agent safety.
Unlike the scripted stories above, this runs the real checker in your browser. Hover a form for its type, Alt-click to select one and read it in the inspector, and try Introduce error, then repair the source or press Reset. To define a vocabulary of your own, open the domain language playground.
A macro adds a keyword in an afternoon. It doesn't add a typing rule.
Lisp makes new syntax cheap and checking expensive. A bad call to a macro fails inside its expansion, at runtime, or in generated code nobody reads. Typed Lisps check programs against rules their authors chose. A domain with rules of its own (every workflow step gets the input it needs, a query sees only its entity's fields, a rule never touches a forbidden capability) still needs its own parser, checker, and tooling.
That is the old Lisp curse: every team ends up with a language only its authors understand. Coding agents make new code cheap in every language, so the curse is spreading. Forma doesn't try to stop teams from building their own languages. It makes those languages agree on what a well-typed program is, so a private language still has a contract someone else can check.
01
entity is not built into the compiler. A prelude describes it with form: the type of each slot, the name it declares, the names its predicates can see, and the typed output it builds.
(form (entity name fields {:keys [doc role id-pattern tier]})
"A named record of attributes."
:examples
[[(entity Person {:name String :age (Option Int)})]]
:types
{
:name (Declares SchemaDecl)
:fields (Record Type)
:doc (Option String)
:role (Option String)
:id-pattern (Option String)
:tier (Option (Union :user :meta))}
:ir EntityDeclarationIR
:extensions {:artifact {:validators ["domain-payload"]}}
{
:kind (if (= tier :meta) "MetaEntity" "Entity")
:name name
:fields (fields->ir name fields)
:doc doc
:role role
:idPattern id-pattern})(entity Department {:name String})
(entity Employee {:name String
:department (Option (Id Department))
:active Bool})
(query employee-directory
:from Employee
:where active
:select [name department])The form resolves Employee, checks :where as a Bool with the entity's fields in scope, and projects the selected fields into typed IR. The projection is checked against the form's declared IR type, so a prelude can't emit a payload its contract doesn't describe. Open this example → Or explore Forma for ontology modeling →
Each declaration in the artifact also records a content identity for its payload contract: a hash of the IR type and every type it reaches. Two forms with different syntax that build the same IR share an identity, and a consumer can reject a payload built against another definition.
Swap the prelude and you have a different language on the same checked core.
02
Operations check Effect<A, E, R> contracts. A reviewer reads one line instead of a call graph.
(error ConsoleUnavailable {:message String})
(service Console
(: print (-> String (Effect Unit [ConsoleUnavailable] []))))
(: log (-> String (Effect Unit [ConsoleUnavailable] [Console.print])))
(define log [message]
(do! [_ (Console.print message)]
(succeed nil)))(-> String (Effect Unit [ConsoleUnavailable] [Console.print]))import { Context, Effect, Schema } from "effect";
export class ConsoleUnavailable extends Schema.TaggedError<ConsoleUnavailable>()("ConsoleUnavailable", {
message: Schema.String,
}) {}
export class Console extends Context.Service<
Console,
{
readonly print: (arg0: string) => Effect.Effect<void, ConsoleUnavailable>;
}
>()("Console") {}
export const log = (message: string): Effect.Effect<void, ConsoleUnavailable, Console> =>
Effect.gen(function* () {
const consoleService = yield* Console;
yield* consoleService.print(message);
return;
});The contract survives code generation.
Requirements are lowered to Context services in the generated Effect TypeScript. Building with Effect? Read what Forma adds, and what it costs → Or explore Forma for Effect UI →
03
When a generated file fails to compile, the mistake is usually somewhere else: a missing entry in a YAML file three directories away, and the error never mentions it.
In the live playground above, choose Explore typed Lisp & effects, then press Introduce error: the body still calls Console.print, but the signature declares no requirements. The Effect checker rejects the operation and points at the call you wrote. Click the problem to jump to its source, then add Console.print to the signature, or press Reset, and generation resumes.
04
A form's descriptor already teaches the compiler its checks, the language server its hover and search, and this site its reference pages. Nobody maintains a second description of the keyword for tooling.
(form (rule name lanes clause ...) …)
│
├─ compiler slot checks · HM types · effect sets
├─ editor diagnostics · hover · search by IR type
├─ reference generated prelude pages
└─ artifacts typed IR · Effect TypeScriptA new language should feel as supported as a built-in one.
Workspace search ranks forms and definitions by their names and documentation, and filters by the IR type they produce. An author or a coding agent can ask which form builds an Endpoint instead of grepping preludes; the language server answers the same query as workspace/symbol.
05
Types, effects, and contracts don't depend on spelling. The plan is to make every surface a library, Forma's own included, and to let a Lisp dialect plug into the same checker through a language adapter. Elaborators may propose terms and types; a small trusted kernel decides what is well typed.
The first step ships today: Clojure spellings are an ordinary macro library. Part of the reason is practical: coding agents write defn, if-let, and -> out of habit, and a library can accept those spellings where the engine used to reject them. We haven't yet measured whether that reduces repair rounds; the later stages of RFC 0021 wait on that benchmark. See what it does, and what it refuses →
(: quote-for (-> Int (Option Int) String))
(defn quote-for [subtotal coupon]
(-> (after-coupon subtotal coupon)
(+ (shipping-for subtotal))
(str " cents")))(: quote-for (-> Int (Option Int) String))
(: receipt String) ; = "4400 cents"This changes spelling only: if still takes a Bool, and nil is not None. The rest is proposed:
defn, if-let, and friends expand to core Forma. The guide shows a checked example.preludes06
A domain language is worth most where its consumers already are. The plan is to write a policy, schema, or workflow once, check it with one kernel, and emit Clojure, Racket, Scheme, or Common Lisp source that runs on the host a team already operates: no Forma runtime to install, no second type system to adopt.
The design makes a declarative surface invertible, so running a Lisp surface backwards over checked core terms is most of an emitter. The rest is a kernel port and a differential run of the conformance corpus.
core terms one checked program · one contract
│
├─ 1 resugar core → the target's own spellings
├─ 2 kernel port tagged values · match · Option · records
└─ 3 conformance the corpus vs. the TypeScript VM goldens| Target | Surface | Emitter | Where it would run |
|---|---|---|---|
| Clojure | Shipped as preludes/modules/clojure.lisp | Proposed · first | The JVM and JavaScript, from one .cljc file |
| Racket | Proposed brackets and #t are reader switches | Proposed · second | Racket |
| Scheme | Proposed the same reader switches | Proposed · third | R7RS implementations |
| Common Lisp | Proposed last: funcall and #'f are semantics, not spelling | Proposed · last | ANSI implementations such as SBCL |
| All four | One program, checked once | One kernel port each | Pinned against the TypeScript VM's goldens |
Check it once. Run it where the work is.
Only the Clojure spellings library is shipped, and it changes spelling, not semantics. Every emitter here is proposed: effectful programs stay TypeScript-only until a target has an effect runtime, and each back end needs a concrete consumer and a conformance target before it is built. The targets, their semantic gaps, and the gate for each are in RFC 0021 and RFC 0022.
Preludes
Each prelude is one source file. Its reference page is generated from that file: forms, slot types, signatures, and the comments its author wrote.
Plus viewspec, system, compiler, and six host protocol preludes. All preludes →
Prelude explorations (pre-alpha prototypes with editable browser sandboxes): Effect (sandbox), Effect UI (sandbox), Effect Torch (sandbox), Effect PDF (sandbox), Workflows (sandbox), Ontology (sandbox), Email automation (sandbox), and Clojure spellings (sandbox).
For prelude authors
Descriptors are the single source for a keyword. The checker, the editor, and the reference read the same form, so a domain language gets its tooling from the prelude you already wrote.
:pattern, :min-length, :min, and :max on IR fields, checked where the author wrote them and generated as Schema filters.engineforma.json, a verified forma.lock, and committed vendor sources. File modulesengineExamples
Edit the source and step through each compiler pass in your browser. Preview examples label any output that comes from a stored golden.
entity; the source elaborates into typed IR.Open example →Domain languagesThe type says what code can doDrop a capability from the signature and watch the typechecker reject it.Open example →The core languageThe complete pipelineRead, expand, typecheck, eval, and a live JSON target for one program.Open example →Lisp surfacesClojure spellings, checkeddefn, if-let, and -> come from a library, and the guide shows the errors it refuses to paper over.Read the guide →Alternatives
Each approach covers part of this well. Forma's bet is that typing rules belong in libraries, checked by one small core.
| Who writes the typing rules | Checking | Output | Trade-off | |
|---|---|---|---|---|
| Typed Clojure, Typed Racket, Coalton | The type system's authors | Static types for Clojure, Racket, or Common Lisp code | Programs on the host runtime | A domain language gets the host's rules, not its own |
| Turnstile | Language authors, as Racket macros | Whatever the rules say; the rules are trusted | Racket programs | Racket only |
Racket #lang | Language authors | Whatever you build | Programs on the Racket runtime | Hard to embed in a TypeScript or browser stack |
| Schemas (Malli, JSON Schema) | Schema authors | Data, at runtime | Validators | Checks values, not the programs that build them |
| Config languages (CUE, Pkl, Dhall, Nickel) | The language's authors | Strong, for data | JSON, YAML, and other data | No new forms, no effect or capability tracking |
| Forma | Prelude authors, as typed forms | Hindley–Milner inference, form checks, effect sets | Typed IR (application/vnd.forma.ir+json), Effect TypeScript | Pre-alpha, one Lisp surface and one generated target so far |
Engine
One TypeScript engine runs behind a JSON host ABI in Node, the browser, and editor tooling, and stored fixtures pin its behavior.
@forma-language/forma contains the TypeScript engine, host, editor adapters, and language server. The engine runs in Node and in the browser.
forma check, run, test, fmt, repl, and describe serve the human workflow. forma mcp serves agents; createLanguage embeds the same language services.
Fixtures and reviewed goldens pin parsing, typing, evaluation, and IR output, and CI checks the engine against them.
Typed holes such as ?name expose expected types. Diagnostics carry source spans, explanations, and repair information for editors and agents.
WorldVM's world language is a Forma prelude.
Install from npm (Node.js 22.19 or later):
npm install @forma-language/forma effect
npx forma helpOr from a checkout of main (pnpm 10.20):
pnpm install --frozen-lockfile
pnpm exec turbo run build --filter=@forma-language/forma
node packages/forma/dist/cli.mjs helpTo install a tarball packed from main, after that build:
mkdir -p .context/tarballs
pnpm --filter @forma-language/forma pack --pack-destination ../../.context/tarballs
# In your consumer project, use the actual tarball filename printed above:
npm install /absolute/path/to/forma/.context/tarballs/forma-language-forma-*.tgz effect@4.1.1Publishing records the release checks and publication gates.
Before you bet on it
main.main. See Publishing for the distribution contract and release gates..cljc, and Go and Rust Effect hosts are proposals in RFC 0021 and the Effect hosts RFC, not built.working today ✓ reader · formatter · macros ✓ HM inference · effect inference ✓ refined contracts ✓ canonical IR · contract identity ✓ file modules · offline packages ✓ Effect TypeScript + Schema ✓ playground · language server ✓ conformance goldens ✓ human CLI · MCP · createLanguage ✓ typed holes · repair diagnostics not yet ○ npm publication ○ stable host ABI ○ trusted kernel · elaborators ○ Lisp dialect adapters ○ Clojure / Racket / Scheme / CL emitters ○ Go / Rust Effect hosts ○ effect-polymorphic signatures