effx
API reference@effx/compilerlift

plan

API reference for @effx/compiler/lift/plan

plan.ts overview


Exports Grouped by Category


utils

ExportPlan (interface)

A planned export: where it will live, its name, where the name came from and the reference it has.

Signature

export interface ExportPlan {
  readonly target: SourceFileRecord
  readonly name: string
  readonly source: NameSource
  readonly ref: SchemaRef | SymbolRef
}

ExportRefactor (interface)

One export of a refactor: the inline expression it replaces and what the new export holds.

Signature

export interface ExportRefactor {
  readonly code: Refactor["code"]
  readonly subject: string
  readonly cause: Diagnostic
  readonly key: string
  readonly role: PlannedExport["role"]
  /** The file holding the inline expression, its statement start and the exact range being replaced. */
  readonly use: SourceFileRecord
  readonly anchor: SourcePosition
  readonly replace: SourceRange
  readonly plan: ExportPlan
  readonly initializer: Term
  readonly asConst: boolean
}

exportRefactors

The refactors for one planned export. When the export lives in the file that holds the inline expression, one refactor inserts and replaces; otherwise the target file gets the export and the using file the import and the replacement.

Signature

declare const exportRefactors: (
  ctx: Context,
  input: ExportRefactor
) => Result.Result<ReadonlyArray<Refactor>, ExportPlacementFailure>

namedIn

Whether a reference is already named in a file by a runtime value binding.

Signature

declare const namedIn: (file: SourceFileRecord, reference: RefLike) => Option.Option<string>

planExport

Pins win; otherwise derived is reserved collision-free in home. A failure names why the plan is unusable (an unknown module, a taken name, an identity that cannot be formed) and reserves nothing.

Signature

declare const planExport: (
  ctx: Context,
  key: string,
  derived: string,
  home: SourceFileRecord,
  kind: "schema" | "value"
) => Result.Result<ExportPlan, string>

refsOf

Every reference a term names, in print order, without duplicates.

Signature

declare const refsOf: (term: Term) => ReadonlyArray<RefLike>

schemaNamespace

The Schema namespace reference new code is written against: the generator's own logical reference.

Signature

declare const schemaNamespace: (ctx: Context) => SymbolRef

structTerm

Schema.Struct(fields) as a term.

Signature

declare const structTerm: (ctx: Context, fields: Term) => Term

On this page