// Package "explanation" provides a observer to gather the reasoning during the // reduction, and present a thorough explanation to the user for each step. package explanation import ( "fmt" "git.maximhutz.com/max/lambda/internal/engine" "git.maximhutz.com/max/lambda/pkg/lambda" ) // Track the reductions made by a reduction proess. type Tracker struct { process *engine.Engine } // Attaches a new explanation tracker to a process. func Track(process *engine.Engine) *Tracker { tracker := &Tracker{process: process} process.On("start", tracker.Start) process.On("step", tracker.Step) return tracker } func (t *Tracker) Start() { fmt.Println(lambda.Stringify(*t.process.Expression)) } func (t *Tracker) Step() { fmt.Println(" =", lambda.Stringify(*t.process.Expression)) }