Documentation
¶
Overview ¶
Package codegen is the CODEGEN STRATUM: erased intermediate representation to target source, kept behind the Backend interface so a new deployment target is one plugin, not a fork. Dependent types are a build-time discipline; what deploys is the erasure — the shadow.
THE SHADOW RULE (CLAUDE.md): any optimization IR is built on erased, throwaway codegen output, NEVER on the immutable core/store. The core is the source of truth and identity; codegen mutates only its own shadow.
v1 ships one Backend (JavaScript); the interface exists so a later version adds targets without a rewrite.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// Target names the backend (e.g. "js").
Target() string
// Emit lowers an erased program to target source.
Emit(p Program) (TargetSource, error)
}
Backend is the codegen stratum interface: it turns an erased Program into target source. One implementation ships per supported target.
type CtorSpec ¶
CtorSpec is one constructor of an emitted datatype: its bound name, its 0-based tag, and the total number of curried parameters it takes (datatype parameters + its own arguments; parameters arrive erased).
type DataSpec ¶
DataSpec is one datatype: its eliminator's bound name, the number of datatype parameters, and its constructors in declaration order. Rec mirrors core.CtorSig.Rec for building recursive calls in the eliminator.
type IGlobal ¶
type IGlobal struct {
Name string
}
IGlobal is a reference to a top-level definition, constructor, or eliminator, by the name the emitted program binds it to.
type IUnit ¶
type IUnit struct{}
IUnit is the erased token: every type, proof, and 0-quantity value.
type Ir ¶
type Ir interface {
// contains filtered or unexported methods
}
Ir is an erased term. Sealed like core.Tm.
type JS ¶
type JS struct{}
JS is the v1 backend: boring JavaScript. Everything is curried one-argument arrow functions; constructors build {tag, args} records; eliminators are switch-dispatch with recursive calls for the inductive hypotheses; the erased token is null. The output runs under node with no dependencies.
type NatSpec ¶
type NatSpec struct {
Zero, Succ, ElimName string
}
NatSpec marks a datatype as the `builtin nat` binding (ergonomics rung 6): the backend may then compile it to native machine integers — zero/succ/the eliminator become arithmetic and a loop — instead of unary records. The core stays Peano and provable; only the shadow gets fast.
type Program ¶
type Program struct {
Datas []DataSpec
Defs []DefSpec
// Nat, when non-nil, names the builtin-nat data group for fast-path
// compilation.
Nat *NatSpec
// Main, when non-empty, names the definition whose value the emitted
// program prints on run.
Main string
}
Program is a whole erased program in definition order (acyclic, so the order is also the emission order).
type TargetSource ¶
type TargetSource string
TargetSource is emitted source for some concrete backend target.