fastsolver

package
v0.0.0-...-2561dba Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fastsolver implements very fast type unification.

Index

Constants

View Source
const (
	// Name is the prefix for our solver log messages.
	Name = "fast"

	// OptimizationNotImplemented is a placeholder magic flag we can use.
	OptimizationNotImplemented = "not-implemented"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FastInvariantSolver

type FastInvariantSolver struct {
	// Strategy is a series of methodologies to heuristically improve the
	// solver.
	Strategy map[string]string

	// UnifiedState stores a common representation of our unification vars.
	UnifiedState *types.UnifiedState

	Debug bool
	Logf  func(format string, v ...interface{})
	// contains filtered or unexported fields
}

FastInvariantSolver is a fast invariant solver based on union find. It is intended to be computationally efficient.

func (*FastInvariantSolver) Init

func (obj *FastInvariantSolver) Init(init *unification.Init) error

Init contains some handles that are used to initialize the solver.

func (*FastInvariantSolver) Solve

Solve runs the invariant solver. It mutates the .Data field in the .Uni unification variables, so that each set contains a single type. If each of the sets contains a complete type that no longer contains any ?1 type fields, then we have succeeded to unify all of our invariants. If not, then our list of invariants must be ambiguous. This is O(N*K) where N is the number of invariants, and K is the size of the maximum type. Eg a list of list of map of int to str would be of size three. (TODO: or is it four?)

Jump to

Keyboard shortcuts

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