repl

package
v0.3.28 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Overview

Package repl implements TypeRB's project-aware interactive evaluator. Every accepted input is compiled through the normal project pipeline before its typed IR is evaluated.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Complete

func Complete(source string) bool

Complete reports whether source is a complete REPL submission. It uses the lossless lexer so keywords inside strings and comments do not affect nesting.

func Inspect

func Inspect(value Value) string

func Run

func Run(options Options) error

Types

type Compilation

type Compilation struct {
	Session            *compiler.Artifact
	Artifacts          []*compiler.Artifact
	Programs           []*ir.Program
	HiddenPreludeLines int
}

type CompileFunc

type CompileFunc func(source string) (*Compilation, error)

type Evaluator

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

func NewEvaluator

func NewEvaluator(stdout io.Writer, mode string) *Evaluator

func (*Evaluator) Close added in v0.2.0

func (e *Evaluator) Close() error

func (*Evaluator) Evaluate

func (e *Evaluator) Evaluate(statements []ir.Statement, module string) (Result, error)

func (*Evaluator) EvaluateContext

func (e *Evaluator) EvaluateContext(ctx context.Context, statements []ir.Statement, module string) (Result, error)

func (*Evaluator) LoadDefinitions

func (e *Evaluator) LoadDefinitions(program *ir.Program)

func (*Evaluator) LoadProject

func (e *Evaluator) LoadProject(programs []*ir.Program, sessionModule string) error

type Options

type Options struct {
	Mode        string
	ProjectName string
	Version     string
	Stdin       io.Reader
	Stdout      io.Writer
	Stderr      io.Writer
	Interactive bool
	HistoryFile string
	ProjectRoot string
	Compile     CompileFunc
	Initial     *Compilation
	Candidates  languageservice.Context
	// contains filtered or unexported fields
}

type Result

type Result struct {
	Value          Value
	Display        bool
	MutableBinding bool
}

type Value

type Value struct {
	Type types.Type
	Data any
}

Jump to

Keyboard shortcuts

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