Extension
API reference for @effx/compiler/Extension
Extension.ts overview
Exports Grouped by Category
utils
Analysis (type alias)
Signature
type Analysis = (ir: ApplicationIR, index: GraphIndex, context: AnalysisContext) => ReadonlyArray<Diagnostic>Contribution
Signature
declare const Contribution: {
empty: { nodes: Array<never>; edges: Array<never>; diagnostics: Array<never> }
make: (
nodes?: ReadonlyArray<Node>,
edges?: ReadonlyArray<Edge>,
diagnostics?: ReadonlyArray<Diagnostic>
) => Contribution
diagnostics: (...diagnostics: ReadonlyArray<Diagnostic>) => Contribution
concat: (contributions: Iterable<Contribution>) => Contribution
}Contribution (interface)
What one annotation on one declaration contributes to the IR. Never behaviour.
Signature
export interface Contribution {
readonly nodes: ReadonlyArray<Node>
readonly edges: ReadonlyArray<Edge>
readonly diagnostics: ReadonlyArray<Diagnostic>
}EndpointFragment (type alias)
What an extension appends to the generated HTTP endpoint of an operation (spec 0020 §6): zero or more method-call suffixes, appended after the generator's own annotations. Pure and total: a part carries the neutral term of its suffix, so the generator registers the imports it needs when it prints the file.
Signature
type EndpointFragment = (
operation: OperationNode,
ctx: { readonly ir: ApplicationIR; readonly index: GraphIndex }
) => ReadonlyArray<EndpointFragmentPart>EndpointFragmentPart (interface)
One method-call suffix of a generated endpoint (it starts with ., e.g. .annotate(K, v)).
Signature
export interface EndpointFragmentPart {
readonly call: MethodCall
}Expand (type alias)
A cross-annotation pre-pass over the collected declarations, run before any interpreter (spec 0020 §3,
the 0013 seam). Pure; it may rewrite annotations (source sugar becomes ordinary annotations) but never
adds IR. declarations replaces the input's, in the order returned.
Signature
type Expand = (collected: Collected) => ExpansionExpansion (interface)
What a pre-pass leaves of Collected.declarations, and the diagnostics it found.
Signature
export interface Expansion {
readonly declarations: ReadonlyArray<Declaration>
readonly diagnostics: ReadonlyArray<Diagnostic>
}Extension (interface)
Signature
export interface Extension {
readonly name: string
/** Entry declarations, Schema-decoded and collision-checked with the bundled catalogue before frontend analysis. */
readonly diagnosticEntries?: ReadonlyArray<DiagnosticEntry>
/** Definitions this extension implements; their plans drive frontend lowering (spec 0020). */
readonly annotations?: ReadonlyArray<DefinitionData>
/**
* The per-definition compiler lift entries `extension()` aggregates (spec 0019 §5, S1). Subsidiary seam
* for `liftRegistryOf(extensions)`; not the old `Extension.lifters` proposal — the definition-owned
* `implement({ lift })` interface is the one that exists.
*/
readonly lifts?: ReadonlyArray<ExtensionLiftEntry>
readonly interpreters: Readonly<Record<string, Interpreter>>
readonly analyses: ReadonlyArray<Analysis>
/**
* An optional pre-pass over Collected, run in extension order. Its diagnostics (including related
* occurrences) are registry-checked before reporting; violations become EFFX0010 and block output.
*/
readonly expand?: Expand
/**
* Endpoint fragments, in declaration order (spec 0020 §6). `extension()` derives one for every
* definition with an `effect` clause; the pipeline hands them to the generators through
* `GenerationContext.fragments`.
*/
readonly fragments?: ReadonlyArray<EndpointFragment>
readonly generators: ReadonlyArray<Generator>
}ExtensionLiftEntry (interface)
One definition-owned compiler lift entry an extension() aggregates (spec 0019 §5, S1): the
definition value the extension declares plus the erased hook implement() built. Subsidiary to
liftRegistryOf(extensions); not the old Extension.lifters proposal — the definition-owned
implement({ lift }) interface is the one that exists.
Signature
export interface ExtensionLiftEntry {
readonly definition: DefinitionData
readonly lift: LiftImplementation
}GeneratedFile (interface)
Signature
export interface GeneratedFile {
readonly path: string
readonly contents: string
}Generator (type alias)
Signature
type Generator = (
ir: ApplicationIR,
index: GraphIndex,
context?: GenerationContext
) => Effect.Effect<ReadonlyArray<GeneratedFile>, CompilerFault>Interpreter (type alias)
Signature
type Interpreter = (annotation: Annotation, declaration: Declaration, ctx: InterpretContext) => Contribution