refactor: extract abstract Expression interface
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().
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Package "explanation" provides a observer to gather the reasoning during the
|
||||
// Package "explanation" provides an observer to gather the reasoning during the
|
||||
// reduction, and present a thorough explanation to the user for each step.
|
||||
package plugins
|
||||
|
||||
@@ -6,10 +6,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"git.maximhutz.com/max/lambda/internal/engine"
|
||||
"git.maximhutz.com/max/lambda/pkg/lambda"
|
||||
)
|
||||
|
||||
// Track the reductions made by a reduction proess.
|
||||
// Track the reductions made by a reduction process.
|
||||
type Explanation struct {
|
||||
process *engine.Engine
|
||||
}
|
||||
@@ -24,9 +23,9 @@ func NewExplanation(process *engine.Engine) *Explanation {
|
||||
}
|
||||
|
||||
func (t *Explanation) Start() {
|
||||
fmt.Println(lambda.Stringify(*t.process.Expression))
|
||||
fmt.Println((*t.process.Expression).String())
|
||||
}
|
||||
|
||||
func (t *Explanation) Step() {
|
||||
fmt.Println(" =", lambda.Stringify(*t.process.Expression))
|
||||
fmt.Println(" =", (*t.process.Expression).String())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user