Documentation ¶
Overview ¶
Package fastsolver implements very fast type unification.
Index ¶
Constants ¶
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 ¶
func (obj *FastInvariantSolver) Solve(ctx context.Context, data *unification.Data) (*unification.InvariantSolution, error)
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?)