eval

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: MIT, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugValue added in v1.2.0

func DebugValue(v Value) string

DebugValue provides detailed debug information about a Value.

func EvalNBE added in v1.2.0

func EvalNBE(t ast.Term) ast.Term

EvalNBE is a convenience function that evaluates and reifies a term using NbE.

func NeutralEqual added in v1.2.0

func NeutralEqual(n1, n2 Neutral) bool

NeutralEqual compares two Neutrals for structural equality.

func Normalize

func Normalize(t ast.Term) ast.Term

Normalize reduces a term to weak head normal form using beta-reduction and projections.

func NormalizeNBE added in v1.2.0

func NormalizeNBE(t ast.Term) string

NormalizeNBE normalizes a term using NbE and returns its string representation. This function provides compatibility with existing test expectations.

func PrettyNeutral added in v1.2.0

func PrettyNeutral(n Neutral) string

PrettyNeutral converts a Neutral to a stable string representation for testing.

func PrettyValue added in v1.2.0

func PrettyValue(v Value) string

PrettyValue converts a Value to a stable string representation for testing. This ensures deterministic output for golden tests.

func Reify added in v1.2.0

func Reify(v Value) ast.Term

Reify converts a Value back to an ast.Term.

func SprintNeutral added in v1.2.0

func SprintNeutral(n Neutral) string

SprintNeutral returns a string representation of a Neutral for debugging and testing.

func SprintValue added in v1.2.0

func SprintValue(v Value) string

SprintValue returns a string representation of a Value for debugging and testing.

func ValueEqual added in v1.2.0

func ValueEqual(v1, v2 Value) bool

ValueEqual compares two Values for structural equality (useful for testing).

Types

type Closure added in v1.2.0

type Closure struct {
	Env  *Env
	Term ast.Term
}

Closure captures an environment and a term for lazy evaluation.

type Env added in v1.2.0

type Env struct {
	Bindings []Value
}

Env represents an evaluation environment mapping de Bruijn indices to Values.

func (*Env) Extend added in v1.2.0

func (e *Env) Extend(v Value) *Env

Extend adds a new binding to the front of the environment.

func (*Env) Lookup added in v1.2.0

func (e *Env) Lookup(ix int) Value

Lookup retrieves a value by de Bruijn index.

type Head struct {
	Var  int    // de Bruijn index
	Glob string // global name
}

Head represents the head of a neutral term.

type Neutral added in v1.2.0

type Neutral struct {
	Head Head
	Sp   []Value
}

Neutral represents stuck terms with a head and spine of arguments.

type VGlobal added in v1.2.0

type VGlobal struct{ Name string }

VGlobal represents global constants.

type VLam added in v1.2.0

type VLam struct{ Body *Closure }

VLam represents lambda closures.

type VNeutral added in v1.2.0

type VNeutral struct{ N Neutral }

VNeutral represents neutral terms (stuck computations).

type VPair added in v1.2.0

type VPair struct{ Fst, Snd Value }

VPair represents pairs in WHNF.

type VPi added in v1.2.0

type VPi struct {
	A Value
	B *Closure
}

VPi represents Pi type closures (optional for now).

type VSigma added in v1.2.0

type VSigma struct {
	A Value
	B *Closure
}

VSigma represents Sigma type closures (optional for now).

type VSort added in v1.2.0

type VSort struct{ Level int }

VSort represents universe sorts.

type Value added in v1.2.0

type Value interface {
	// contains filtered or unexported methods
}

Value is the semantic domain for NbE.

func Apply added in v1.2.0

func Apply(fun Value, arg Value) Value

Apply performs function application in the semantic domain.

func Eval added in v1.2.0

func Eval(env *Env, t ast.Term) Value

Eval evaluates a term in an environment to weak head normal form.

func Fst added in v1.2.0

func Fst(v Value) Value

Fst performs first projection in the semantic domain.

func Reflect added in v1.2.0

func Reflect(neu Neutral) Value

Reflect converts a Neutral to a Value (identity function, but useful for API completeness).

func Snd added in v1.2.0

func Snd(v Value) Value

Snd performs second projection in the semantic domain.

Jump to

Keyboard shortcuts

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