link

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugBuiltinTypes

func DebugBuiltinTypes()

func RegisterAdtModule

func RegisterAdtModule(ml *ModuleLinker)

RegisterAdtModule creates and registers the $adt module interface for ADT constructors

func RegisterBuiltinModule

func RegisterBuiltinModule(ml *ModuleLinker)

RegisterBuiltinModule creates and registers the $builtin module interface

func VerifyIdempotence

func VerifyIdempotence(prog *core.Program, registry *types.DictionaryRegistry) error

VerifyIdempotence checks that linking is idempotent

Types

type CompileUnit

type CompileUnit interface {
	GetCore() *core.Program
	GetModuleID() string
}

CompileUnit represents a compiled module (shared interface to avoid circular dependency)

type CycleError

type CycleError struct {
	Code  string
	Cycle []ModuleID
}

CycleError represents a dependency cycle error

func (*CycleError) Error

func (e *CycleError) Error() string

func (*CycleError) GetSuggestion

func (e *CycleError) GetSuggestion() string

GetSuggestion returns a fix suggestion for the cycle error

type GlobalEnv

type GlobalEnv map[string]*ImportedSym

GlobalEnv maps imported names to their symbol information

type ImportedSym

type ImportedSym struct {
	Ref    core.GlobalRef
	Type   *types.Scheme
	Purity bool
}

ImportedSym represents an imported symbol with its type information

type LinkDiagnostics

type LinkDiagnostics struct {
	ResolutionTrace []string // Paths tried during resolution
	Suggestions     []string // Suggestions for fixes
}

LinkDiagnostics contains diagnostic information from linking process (separate from LinkReport which is for structured error output)

type LinkOptions

type LinkOptions struct {
	DryRun    bool   // If true, only check for errors without modifying
	Verbose   bool   // If true, print detailed linking information
	Namespace string // Default namespace for lookups (usually "prelude")
}

LinkOptions configures the linking process

type LinkResult

type LinkResult struct {
	Program  *core.Program
	Errors   []error
	Warnings []string
	Resolved map[string]bool // Dictionary keys that were resolved
}

LinkResult contains the result of linking

type Linker

type Linker struct {
	// contains filtered or unexported fields
}

Linker resolves dictionary references to concrete implementations

func NewLinker

func NewLinker() *Linker

NewLinker creates a new linker without a registry (for REPL)

func NewLinkerWithRegistry

func NewLinkerWithRegistry(registry *types.DictionaryRegistry) *Linker

NewLinkerWithRegistry creates a new linker with the given registry

func (*Linker) AddDictionary

func (l *Linker) AddDictionary(key string, dict core.DictValue)

AddDictionary adds a dictionary to the linker (for REPL)

func (*Linker) DryRun

func (l *Linker) DryRun(expr core.CoreExpr) []string

DryRun performs a dry run to find required instances

func (*Linker) GetErrors

func (l *Linker) GetErrors() []error

GetErrors returns all linking errors

func (*Linker) GetWarnings

func (l *Linker) GetWarnings() []string

GetWarnings returns all linking warnings

func (l *Linker) Link(expr core.CoreExpr) (core.CoreExpr, error)

Link links a single expression (simplified for REPL)

func (*Linker) LinkProgram

func (l *Linker) LinkProgram(prog *core.Program, opts LinkOptions) (*core.Program, error)

LinkProgram resolves all dictionary references in a Core program

func (*Linker) LinkWithResult

func (l *Linker) LinkWithResult(prog *core.Program, opts LinkOptions) LinkResult

LinkWithResult performs linking and returns detailed results

type ModuleID

type ModuleID string

ModuleID represents a module identifier

type ModuleLinker

type ModuleLinker struct {
	// contains filtered or unexported fields
}

ModuleLinker manages module interfaces and cross-module resolution

func NewModuleLinker

func NewModuleLinker(loader ModuleLoader) *ModuleLinker

NewModuleLinker creates a new module linker

func (*ModuleLinker) BuildGlobalEnv

func (ml *ModuleLinker) BuildGlobalEnv(imports []*ast.ImportDecl) (GlobalEnv, *LinkDiagnostics, error)

BuildGlobalEnv constructs the global environment for imports

func (*ModuleLinker) GetIface

func (ml *ModuleLinker) GetIface(path string) *iface.Iface

GetIface retrieves a module interface by path

func (*ModuleLinker) GetLoadedModules

func (ml *ModuleLinker) GetLoadedModules() map[string]*iface.Iface

GetLoadedModules returns all loaded module interfaces

func (*ModuleLinker) RegisterIface

func (ml *ModuleLinker) RegisterIface(iface *iface.Iface)

RegisterIface registers a module interface

func (*ModuleLinker) Resolver

func (ml *ModuleLinker) Resolver() *Resolver

Resolver returns a GlobalResolver for the evaluator

func (*ModuleLinker) TopoSortFromRoot

func (ml *ModuleLinker) TopoSortFromRoot(root string, loaded map[string]*loader.LoadedModule) ([]ModuleID, error)

TopoSortFromRoot performs topological sorting starting from a single root module Input: root module ID and map of already-loaded modules with their import lists Output: sorted ModuleIDs in dependency order (dependencies first)

type ModuleLoader

type ModuleLoader interface {
	LoadInterface(modulePath string) (*iface.Iface, error)
	EvaluateExport(ref core.GlobalRef) (eval.Value, error)
}

ModuleLoader is the interface for loading and evaluating modules

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver implements GlobalResolver for the evaluator

func NewResolver

func NewResolver(linker *ModuleLinker) *Resolver

NewResolver creates a new resolver backed by a module linker

func (*Resolver) InvalidateAll

func (r *Resolver) InvalidateAll()

InvalidateAll clears the entire cache

func (*Resolver) InvalidateModule

func (r *Resolver) InvalidateModule(module string)

InvalidateModule clears the cache for a specific module

func (*Resolver) RegisterCompiledModule

func (r *Resolver) RegisterCompiledModule(moduleID string, unit CompileUnit)

RegisterCompiledModule adds a compiled module for on-demand evaluation

func (*Resolver) ResolveValue

func (r *Resolver) ResolveValue(ref core.GlobalRef) (eval.Value, error)

ResolveValue resolves a global reference to its value

func (*Resolver) SetBuiltinLookup

func (r *Resolver) SetBuiltinLookup(lookup func(string) (eval.Value, bool))

SetBuiltinLookup sets the builtin lookup function (v0.2.0 hotfix) This allows the resolver to access builtin functions from the runtime

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL