Introduce pkg/expr.Expression as a base interface for all evaluatable expression types, enabling future support for multiple evaluation modes (SKI combinators, typed lambda calculus, etc.). - Add pkg/expr/expr.go with Expression interface requiring String() method. - Update lambda.Expression to embed expr.Expression. - Add String() method to Abstraction, Application, and Variable types. - Update plugins to use String() instead of lambda.Stringify().
24 lines
416 B
Go
24 lines
416 B
Go
package plugins
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
"git.maximhutz.com/max/lambda/internal/engine"
|
|
)
|
|
|
|
type Logs struct {
|
|
logger *slog.Logger
|
|
process *engine.Engine
|
|
}
|
|
|
|
func NewLogs(logger *slog.Logger, process *engine.Engine) *Logs {
|
|
plugin := &Logs{logger, process}
|
|
process.On(engine.StepEvent, plugin.Step)
|
|
|
|
return plugin
|
|
}
|
|
|
|
func (t *Logs) Step() {
|
|
t.logger.Info("reduction", "tree", (*t.process.Expression).String())
|
|
}
|