36 lines
819 B
Go
36 lines
819 B
Go
package registry
|
|
|
|
import (
|
|
"git.maximhutz.com/max/lambda/pkg/engine"
|
|
)
|
|
|
|
// A Process is a type-erased reduction process that operates on Expr values.
|
|
type Process interface {
|
|
engine.Process[Expr]
|
|
|
|
// InType returns the name of the representation this process operates on.
|
|
InType() string
|
|
}
|
|
|
|
// A registeredProcess adapts a typed engine.Process[T] into the type-erased
|
|
// Process interface. It wraps the result of Get into an Expr.
|
|
type registeredProcess[T any] struct {
|
|
process engine.Process[T]
|
|
inType string
|
|
}
|
|
|
|
func (p registeredProcess[T]) InType() string { return p.inType }
|
|
|
|
func (p registeredProcess[T]) Get() (Expr, error) {
|
|
s, err := p.process.Get()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return NewExpr(p.inType, s), nil
|
|
}
|
|
|
|
func (p registeredProcess[T]) Step(i int) bool {
|
|
return p.process.Step(i)
|
|
}
|