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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
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 ¶ added in v1.0.0
type IUnit struct{}
IUnit is the erased token: every type, proof, and 0-quantity value.
type IVar ¶ added in v1.0.0
type IVar struct {
Idx int
}
IVar is a bound variable (de Bruijn index, as in core).
type Ir ¶ added in v1.0.0
type Ir interface {
// contains filtered or unexported methods
}
Ir is an erased term. Sealed like core.Tm.
type JS ¶ added in v1.0.0
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 Program ¶ added in v1.0.0
type Program struct {
Datas []DataSpec
Defs []DefSpec
// 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.