GlispGlisp
Home
Guide
Playground
  • Overview
  • Syntax
  • Types
  • Evaluation
  • Host API
API
  • English
  • 日本語
GitHub
Home
Guide
Playground
  • Overview
  • Syntax
  • Types
  • Evaluation
  • Host API
API
  • English
  • 日本語
GitHub
  • API

    • glisp
    • build
    • check
    • eval
    • expand
    • expectedType
    • infer
    • lex
    • parse
    • print
    • session
    • types

glisp


glisp / types

types

Classes

AccessAST

Defined in: types.ts:237

Accessor sugar: target.key. Has the same evaluation semantics as Call(target, [Lit(key)]), but kept as a distinct kind for unparse.

Extends

  • ASTNode

Constructors

Constructor

new AccessAST(target, key): AccessAST

Defined in: types.ts:239

Parameters
ParameterType
targetAST
keystring | number
Returns

AccessAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
keyreadonlystring | number---
kindreadonly"access"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
targetreadonlyAST---
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:246

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


abstract ASTNode

Defined in: types.ts:62

Base class for all AST nodes. Subclasses set kind as a literal type so the class hierarchy doubles as a discriminated union when narrowing.

Extended by

  • LitAST
  • HostAST
  • SymAST
  • CallAST
  • AccessAST
  • VecAST
  • RecordAST
  • LetAST
  • FnAST
  • PathAST
  • QuoteAST
  • UnquoteAST
  • SpreadAST
  • SpliceAST
  • MetaAST

Constructors

Constructor

new ASTNode(): ASTNode

Returns

ASTNode

Properties

PropertyModifierTypeDescription
kindabstractstring-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.
trivia?readonlyTrivia-

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

printStructural()

abstract printStructural(): string

Defined in: types.ts:100

Builder-style rendering. Used when no source range is attached.

Returns

string


CallAST

Defined in: types.ts:211

Application AST. args is positional; kwargs are keyword arguments (any positional parameter may be passed by name — see syntax.md).

Spread arguments at the call site are represented as SpreadAST inside args (e.g. (f a ...xs b) becomes args = [a, spread(xs), b]).

Extends

  • ASTNode

Constructors

Constructor

new CallAST(head, args, kwargs?): CallAST

Defined in: types.ts:213

Parameters
ParameterType
headAST
argsreadonly AST[]
kwargs?ReadonlyMap<string, AST>
Returns

CallAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
argsreadonlyreadonly AST[]---
headreadonlyAST---
kindreadonly"call"-ASTNode.kind-
kwargs?readonlyReadonlyMap<string, AST>---
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:221

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


FnAST

Defined in: types.ts:376

Function literal. With body: null it expresses a pure function-type (no implementation), used in type positions.

Chain methods .withGenerics(...) and .withBody(expr) produce a new FnAST; the original is unchanged. The method names use with* to avoid clashing with the same-name fields.

Extends

  • ASTNode

Constructors

Constructor

new FnAST(generics, params, returnType, body): FnAST

Defined in: types.ts:378

Parameters
ParameterType
genericsreadonly string[]
paramsreadonly FnParam[]
returnTypeAST
bodyAST | null
Returns

FnAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
bodyreadonlyAST | null---
genericsreadonlyreadonly string[]---
kindreadonly"fn"-ASTNode.kind-
paramsreadonlyreadonly FnParam[]---
returnTypereadonlyAST---
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:398

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural

withBody()

withBody(expr): FnAST

Defined in: types.ts:394

Return a new FnAST with the given body expression (turns a function type into a function literal).

Parameters
ParameterType
exprAST
Returns

FnAST

withGenerics()

withGenerics(…names): FnAST

Defined in: types.ts:388

Return a new FnAST with the given generic-parameter names.

Parameters
ParameterType
…namesstring[]
Returns

FnAST


HostAST

Defined in: types.ts:162

AST node carrying a host-side value verbatim. Used by the host API to surface values that the source language cannot otherwise express: type values (number, _, …), typed host fns (+, *, …), IO actions, and the like. Evaluating a HostAST yields its value unchanged.

print() cannot round-trip a host value back to source — instead it shows a sensible label (the type’s name for type values, <host-fn> for typed host fns, <host-value> otherwise). For idempotent display of bound names, callers should prefer toAst which looks the value up in env and returns the bound symbol when available.

Extends

  • ASTNode

Constructors

Constructor

new HostAST(value): HostAST

Defined in: types.ts:164

Parameters
ParameterType
valueunknown
Returns

HostAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
kindreadonly"host"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia
valuereadonlyunknown---

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:168

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


LetAST

Defined in: types.ts:328

Let-block {name = expr ... body}. Bindings are self-referential (any binding may reference any other by name, in any order, which supports recursive definitions). body is the trailing expression whose value the block reduces to; body: null means the block itself is the record of bindings.

Extends

  • ASTNode

Constructors

Constructor

new LetAST(bindings, body): LetAST

Defined in: types.ts:330

Parameters
ParameterType
bindingsreadonly readonly [string, AST][]
bodyAST | null
Returns

LetAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
bindingsreadonlyreadonly readonly [string, AST][]---
bodyreadonlyAST | null---
kindreadonly"let"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:337

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


LitAST

Defined in: types.ts:134

AST node for a primitive literal: number, string, boolean, or unit (()). Evaluates to its value unchanged.

Extends

  • ASTNode

Constructors

Constructor

new LitAST(value): LitAST

Defined in: types.ts:136

Parameters
ParameterType
valuestring | number | boolean | typeof UNIT
Returns

LitAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
kindreadonly"lit"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia
valuereadonlystring | number | boolean | typeof UNIT---

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:140

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


MetaAST

Defined in: types.ts:512

Metadata-attached expression ^{...} expr. Field is metadata (not meta) to avoid clashing with the .meta() method.

Extends

  • ASTNode

Constructors

Constructor

new MetaAST(metadata, expr): MetaAST

Defined in: types.ts:514

Parameters
ParameterType
metadataRecordAST
exprAST
Returns

MetaAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
exprreadonlyAST---
kindreadonly"meta"-ASTNode.kind-
metadatareadonlyRecordAST---
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:521

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


PathAST

Defined in: types.ts:426

Path atom. A path is a sequence of segments separated by /. Each segment is '..' (go up to parent), a name (descend into a named child), or an integer index (descend into a positional child).

./foo → segments: [‘foo’] …/foo → segments: [‘…’, ‘foo’] …/…/foo → segments: [‘…’, ‘…’, ‘foo’] …/foo/bar → segments: [‘…’, ‘foo’, ‘bar’] ./ → segments: []

Distinguishing path from spread (...): a path always begins with ./ or ../ and contains a /. ...xs (no slash) is a spread.

Extends

  • ASTNode

Constructors

Constructor

new PathAST(segments): PathAST

Defined in: types.ts:428

Parameters
ParameterType
segmentsreadonly (string | number)[]
Returns

PathAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
kindreadonly"path"-ASTNode.kind-
segmentsreadonlyreadonly (string | number)[]---
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:434

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


QuoteAST

Defined in: types.ts:448

Quasiquote: `expr. expr is treated as data, not evaluated, except where an UnquoteAST (~expr) or SpliceAST (...~expr) pops the quote level back. See eval.md — Quasiquoted forms.

Extends

  • ASTNode

Constructors

Constructor

new QuoteAST(expr): QuoteAST

Defined in: types.ts:450

Parameters
ParameterType
exprAST
Returns

QuoteAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
exprreadonlyAST---
kindreadonly"quote"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:454

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


RecordAST

Defined in: types.ts:281

Record literal. Fields are stored as an ordered array of entries — pair fields and spread elements coexist in source order. Duplicate keys (after spreads have been expanded by eval) reduce with last-wins semantics and emit a diagnostic (see syntax.md — Duplicate names).

Extends

  • ASTNode

Constructors

Constructor

new RecordAST(fields, optional?): RecordAST

Defined in: types.ts:283

Parameters
ParameterType
fieldsreadonly RecordEntry[]
optional?ReadonlySet<string>
Returns

RecordAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
fieldsreadonlyreadonly RecordEntry[]---
kindreadonly"record"-ASTNode.kind-
optional?readonlyReadonlySet<string>---
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

get()

get(key): AST | undefined

Defined in: types.ts:296

Look up a statically declared field by name, applying last-wins for duplicate pairs. Spread entries are ignored — they require runtime evaluation to resolve. Returns undefined if the key is absent at the literal level.

Parameters
ParameterType
keystring
Returns

AST | undefined

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:306

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


SpliceAST

Defined in: types.ts:497

Unquote-splice: ...~expr. Only meaningful inside a quasiquote — evaluates expr (popping the quote level) and splices the resulting elements into the surrounding form.

Extends

  • ASTNode

Constructors

Constructor

new SpliceAST(expr): SpliceAST

Defined in: types.ts:499

Parameters
ParameterType
exprAST
Returns

SpliceAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
exprreadonlyAST---
kindreadonly"splice"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:503

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


SpreadAST

Defined in: types.ts:481

Spread: ...expr. Inlines the operand’s elements into the surrounding call / vector / record / quasiquote. Stays as ...expr regardless of whether it appears inside a quasiquote — for the quasiquote-specific “evaluate and splice” form, use SpliceAST (...~expr).

Extends

  • ASTNode

Constructors

Constructor

new SpreadAST(expr): SpreadAST

Defined in: types.ts:483

Parameters
ParameterType
exprAST
Returns

SpreadAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
exprreadonlyAST---
kindreadonly"spread"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:487

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


SymAST

Defined in: types.ts:193

AST node for a bare identifier. Evaluation looks name up in the current env’s binding chain (see eval.md — name resolution). Special-form heads like ?, |>, def, @ arrive here too and are dispatched by name, not by lookup.

Extends

  • ASTNode

Constructors

Constructor

new SymAST(name): SymAST

Defined in: types.ts:195

Parameters
ParameterType
namestring
Returns

SymAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
kindreadonly"sym"-ASTNode.kind-
namereadonlystring---
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:199

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


UnquoteAST

Defined in: types.ts:464

Unquote: ~expr inside a quasiquote. Pops one quote level so the inner expression evaluates in the surrounding env. Outside a quasiquote, an unquote is a parse-time error.

Extends

  • ASTNode

Constructors

Constructor

new UnquoteAST(expr): UnquoteAST

Defined in: types.ts:466

Parameters
ParameterType
exprAST
Returns

UnquoteAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
exprreadonlyAST---
kindreadonly"unquote"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:470

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural


VecAST

Defined in: types.ts:257

Vector literal [e0 e1 ...]. Evaluation produces a JS array; spread elements (...xs) are flattened by the evaluator at this position. In type position, a [T1 T2 ...Trest] shape is read as a tuple type (see types.md).

Extends

  • ASTNode

Constructors

Constructor

new VecAST(elements): VecAST

Defined in: types.ts:259

Parameters
ParameterType
elementsreadonly AST[]
Returns

VecAST

Overrides

ASTNode.constructor

Properties

PropertyModifierTypeDescriptionOverridesInherited from
elementsreadonlyreadonly AST[]---
kindreadonly"vec"-ASTNode.kind-
source?publicSourceRangeOriginal source range. Mutable on construction (the parser stamps it after building the node). Builder-produced nodes leave it undefined and print() falls through to structural rendering.-ASTNode.source
trivia?readonlyTrivia--ASTNode.trivia

Methods

meta()

meta(content): MetaAST

Defined in: types.ts:78

Attach metadata to this node. Returns a new MetaAST wrapping the current expression with a record of the given fields. Plain JS values in the content map are auto-lifted to LitAST.

Parameters
ParameterType
contentMetaContent
Returns

MetaAST

Inherited from

ASTNode.meta

print()

print(): string

Defined in: types.ts:92

Render this AST back to Glisp source. If a source range is stamped, returns the original text verbatim — preserving comments and the exact whitespace layout. Otherwise delegates to printStructural, which each subclass overrides for builder-style emission.

Returns

string

Inherited from

ASTNode.print

printStructural()

printStructural(): string

Defined in: types.ts:263

Builder-style rendering. Used when no source range is attached.

Returns

string

Overrides

ASTNode.printStructural

Interfaces

BindingTarget

Defined in: types.ts:608

Properties

PropertyModifierTypeDescription
astreadonlyAST-
envreadonlyEnv-
type?readonlyunknownOptional declared type for this binding — typically a function parameter’s declared type, eagerly evaluated when the closure was applied. When set, the evaluator casts the resolved value through this type at force time, driving the spec’s “default fallback at typed slots” behavior for closures. The shape is TypeValue (defined in eval.ts) but it lives here as unknown to avoid a circular import — the evaluator’s isTypeValue brand check narrows it back at use sites.

Diagnostic

Defined in: types.ts:637

One error / warning / info entry produced by evaluate, check, or infer. The source pinpoints the offending AST node and the env it was evaluated against, so a host can show the message in context.

Properties

PropertyModifierType
levelreadonlyDiagnosticLevel
messagereadonlystring
sourcereadonlyEvaluationNode

EvaluationNode

Defined in: types.ts:649

The site at which a diagnostic was raised: an (ast, env) pair. The same AST node can be evaluated under different envs (a function called twice from different scopes), so both halves are needed to locate the diagnostic precisely.

Properties

PropertyModifierType
astreadonlyAST
envreadonlyEnv

FnParam

Defined in: types.ts:354

One parameter slot in a FnAST signature: a name, a declared type (as an AST that is evaluated in the function’s captured env), and the optional?: / ...rest markers from source.

Properties

PropertyModifierType
namereadonlystring
optional?readonlyboolean
typereadonlyAST
variadic?readonlyboolean

Frame

Defined in: types.ts:602

A single frame in the env chain.

Properties

PropertyModifierType
astreadonlyAST
bindings?readonlyReadonlyMap<string, BindingTarget>
parentreadonlyEnv

SourceRange

Defined in: types.ts:52

Source-range stamp used to round-trip a parsed AST verbatim. The parser sets this on every node it produces; builder-constructed nodes leave it unset and fall back to structural rendering. The same text reference is shared across all nodes from one parse() call.

Properties

PropertyModifierType
endreadonlynumber
startreadonlynumber
textreadonlystring

Type Aliases

AST

AST = LitAST | HostAST | SymAST | CallAST | AccessAST | VecAST | RecordAST | LetAST | FnAST | PathAST | QuoteAST | UnquoteAST | SpreadAST | SpliceAST | MetaAST

Defined in: types.ts:113

Discriminated union of every AST node kind. Narrow with the is* predicates below or with a switch (ast.kind) over the literal kind field on each variant.


DiagnosticLevel

DiagnosticLevel = "error" | "warning" | "info"

Defined in: types.ts:630

Severity tag attached to a diagnostic.


Diagnostics

Diagnostics = ReadonlySet<Diagnostic>

Defined in: types.ts:658

Read-only collection of diagnostics. Used by APIs that aggregate diagnostics across many call sites (e.g. check).


Env

Env = Frame | null

Defined in: types.ts:597

An environment is a chain of frames, each describing one level of enclosing scope (and providing the ancestor structure that path navigation walks). null is the root sentinel above top-level.


MetaContent

MetaContent = Readonly<Record<string, MetaFieldValue>>

Defined in: types.ts:44


MetaFieldValue

MetaFieldValue = AST | number | string | boolean | Unit

Defined in: types.ts:43

Values accepted by the .meta(...) method: AST nodes, or JS primitives that are auto-lifted to LitAST.


RecordEntry

RecordEntry = readonly [string, AST] | SpreadAST

Defined in: types.ts:273

One entry inside a record literal. Either a [name, value] pair (a normal field), or a SpreadAST (a ...rec element that merges another record’s fields at this position).


Trivia

Trivia = ReadonlyArray<string>

Defined in: types.ts:37

Inter-position trivia (whitespace, comments) attached to each AST node. Slot count and stickiness rules per node type are documented in eval.md.

Builder-constructed ASTs have no trivia; parse-constructed ASTs preserve it.


Unit

Unit = typeof UNIT

Defined in: types.ts:25

Variables

UNIT

const UNIT: unique symbol

Defined in: types.ts:24

The Glisp unit value. Distinguished from null/undefined via a registered Symbol so it survives module boundaries and can never collide with JS-native absence values.

Functions

isAccess()

isAccess(a): a is AccessAST

Defined in: types.ts:576

Parameters

ParameterType
aAST

Returns

a is AccessAST


isCall()

isCall(a): a is CallAST

Defined in: types.ts:575

Parameters

ParameterType
aAST

Returns

a is CallAST


isFn()

isFn(a): a is FnAST

Defined in: types.ts:580

Parameters

ParameterType
aAST

Returns

a is FnAST


isHost()

isHost(a): a is HostAST

Defined in: types.ts:573

Parameters

ParameterType
aAST

Returns

a is HostAST


isLet()

isLet(a): a is LetAST

Defined in: types.ts:579

Parameters

ParameterType
aAST

Returns

a is LetAST


isLit()

isLit(a): a is LitAST

Defined in: types.ts:572

Type-predicate narrowers over the AST union. Each is equivalent to ast.kind === '...' but is written as a TS type-predicate so callers can compose them with Array.filter, Array.find, and similar.

Parameters

ParameterType
aAST

Returns

a is LitAST


isMeta()

isMeta(a): a is MetaAST

Defined in: types.ts:586

Parameters

ParameterType
aAST

Returns

a is MetaAST


isPath()

isPath(a): a is PathAST

Defined in: types.ts:581

Parameters

ParameterType
aAST

Returns

a is PathAST


isQuote()

isQuote(a): a is QuoteAST

Defined in: types.ts:582

Parameters

ParameterType
aAST

Returns

a is QuoteAST


isRecord()

isRecord(a): a is RecordAST

Defined in: types.ts:578

Parameters

ParameterType
aAST

Returns

a is RecordAST


isSplice()

isSplice(a): a is SpliceAST

Defined in: types.ts:585

Parameters

ParameterType
aAST

Returns

a is SpliceAST


isSpread()

isSpread(a): a is SpreadAST

Defined in: types.ts:584

Parameters

ParameterType
aAST

Returns

a is SpreadAST


isSym()

isSym(a): a is SymAST

Defined in: types.ts:574

Parameters

ParameterType
aAST

Returns

a is SymAST


isUnquote()

isUnquote(a): a is UnquoteAST

Defined in: types.ts:583

Parameters

ParameterType
aAST

Returns

a is UnquoteAST


isVec()

isVec(a): a is VecAST

Defined in: types.ts:577

Parameters

ParameterType
aAST

Returns

a is VecAST

Edit this page
Prev
session