effx
API reference@effx/compilerlift

view

API reference for @effx/compiler/lift/view

view.ts overview


Exports Grouped by Category


utils

CallView (interface)

A call with its callee and arguments, for both spellings of a method call.

Signature

export interface CallView {
  readonly callee: Term
  readonly args: ReadonlyArray<Term>
  /** Where each argument sits below the call, for `descend`. */
  readonly argPath: (index: number) => ReadonlyArray<string | number>
  /** A synthetic Chain prefix ends at the preceding method-call span. */
  readonly receiverEndPath: ReadonlyArray<string | number> | undefined
  /** The real receiver position, even when the Member callee is synthetic for a Chain. */
  readonly receiverPath: ReadonlyArray<string | number>
}

Cursor (interface)

A position inside one lowered slot: the term there and its path, so a cause can find its source range.

Signature

export interface Cursor {
  readonly slot: LoweredSlot
  readonly term: Term
  readonly path: TermPath
  readonly sourceRange?: SourceRange
  readonly exactRange?: boolean
  readonly jsonPath?: boolean
}

LoweredSlot (type alias)

Signature

type LoweredSlot = Extract<TermSlot, { readonly _tag: "Lowered" }>

callView

A call, whichever way it is spelled: Call(callee, args) or the last step of Chain(head, calls), whose callee is the member of what precedes it. undefined for any other term.

Signature

declare const callView: (term: Term) => CallView | undefined

descend

A cursor for term, reached from parent through segments.

Signature

declare const descend: (parent: Cursor, term: Term, ...segments: ReadonlyArray<string | number>) => Cursor

fieldOf

A literal object's field cursor retains the field's own source offset.

Signature

declare const fieldOf: (cursor: Cursor, name: string) => Cursor

isJsonObject

A JSON object: neither null nor an array.

Signature

declare const isJsonObject: (json: Schema.Json) => json is Schema.JsonObject

keyName

The property name an object entry key spells: an identifier, or the JSON string literal printTerm prints.

Signature

declare const keyName: (key: string) => string

literalOf

The JSON a term spells when it consists only of literals (Lit, or arrays and objects of literals).

Signature

declare const literalOf: (term: Term) => Option.Option<Schema.Json>

objectOf

A literal object.

Signature

declare const objectOf: (term: Term) => Option.Option<Schema.JsonObject>

rangeOf

The range of the deepest span that contains the cursor's path, else the slot's own range.

Signature

declare const rangeOf: (cursor: Cursor) => SourceRange

receiverOf

A method receiver keeps its recorded span; a virtual Chain prefix never authorizes a guessed edit.

Signature

declare const receiverOf: (cursor: Cursor, view: CallView) => Cursor

refOf

The reference a term is, if it is exactly Ref.

Signature

declare const refOf: (term: Term) => Option.Option<RefLike>

rootOf

The cursor at the root of a lowered slot.

Signature

declare const rootOf: (slot: LoweredSlot) => Cursor

stringField

A string field of a literal object.

Signature

declare const stringField: (object: Schema.JsonObject, key: string) => Option.Option<string>

stringOf

A string literal.

Signature

declare const stringOf: (term: Term) => Option.Option<string>

stringsOf

A literal array of string literals.

Signature

declare const stringsOf: (term: Term) => Option.Option<ReadonlyArray<string>>

unwrap

Removes redundant parentheses; TypeScript-only wrappers never reach a term.

Signature

declare const unwrap: (term: Term) => Term

On this page