## Summary - Added doc comments across the codebase: `pkg/lambda`, `pkg/saccharine`, `pkg/codec`, `pkg/engine`, `pkg/iterator`, `pkg/set`, `pkg/convert`, `internal/registry`, and `cmd/lambda`. - Made lambda and saccharine expression structs use public fields instead of getters, matching `go/ast` conventions. - Removed superfluous constructors for saccharine and lambda expression/statement types in favor of struct literals. - Consolidated saccharine token constructors into a single `NewToken` function. - Removed the unused `trace` package. ## Test plan - [x] `go build ./...` passes. - [x] `go test ./...` passes. - [ ] Verify `go doc` output renders correctly for documented packages. Reviewed-on: #45 Co-authored-by: M.V. Hutz <git@maximhutz.me> Co-committed-by: M.V. Hutz <git@maximhutz.me>
27 lines
777 B
Go
27 lines
777 B
Go
package registry
|
|
|
|
// An Expr is a type-erased lambda calculus expression. It can have any type of
|
|
// representation, so long as that type is known to the registry it is handled
|
|
// by.
|
|
type Expr interface {
|
|
// Repr returns the name of the underlying representation. Two expressions
|
|
// with the same Repr() are assumed to have the same representation type.
|
|
Repr() string
|
|
|
|
// Data returns the underlying expression data.
|
|
Data() any
|
|
}
|
|
|
|
// A baseExpr is the default implementation of Expr.
|
|
type baseExpr struct {
|
|
id string
|
|
data any
|
|
}
|
|
|
|
func (e baseExpr) Repr() string { return e.id }
|
|
|
|
func (e baseExpr) Data() any { return e.data }
|
|
|
|
// NewExpr creates an Expr with the given representation name and data.
|
|
func NewExpr(id string, data any) Expr { return baseExpr{id, data} }
|