docs: document remaining packages and simplify AST types (#45)

## 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>
This commit was merged in pull request #45.
This commit is contained in:
2026-02-10 01:15:41 +00:00
committed by Maxim Hutz
parent 1f486875fd
commit 361f529bdc
33 changed files with 506 additions and 463 deletions

View File

@@ -10,25 +10,25 @@ import "git.maximhutz.com/max/lambda/pkg/lambda"
func ReduceOnce(e lambda.Expression) (lambda.Expression, bool) {
switch e := e.(type) {
case lambda.Abstraction:
body, reduced := ReduceOnce(e.Body())
body, reduced := ReduceOnce(e.Body)
if reduced {
return lambda.NewAbstraction(e.Parameter(), body), true
return lambda.Abstraction{Parameter: e.Parameter, Body: body}, true
}
return e, false
case lambda.Application:
if fn, fnOk := e.Abstraction().(lambda.Abstraction); fnOk {
return fn.Body().Substitute(fn.Parameter(), e.Argument()), true
if fn, fnOk := e.Abstraction.(lambda.Abstraction); fnOk {
return lambda.Substitute(fn.Body, fn.Parameter, e.Argument), true
}
abs, reduced := ReduceOnce(e.Abstraction())
abs, reduced := ReduceOnce(e.Abstraction)
if reduced {
return lambda.NewApplication(abs, e.Argument()), true
return lambda.Application{Abstraction: abs, Argument: e.Argument}, true
}
arg, reduced := ReduceOnce(e.Argument())
arg, reduced := ReduceOnce(e.Argument)
if reduced {
return lambda.NewApplication(e.Abstraction(), arg), true
return lambda.Application{Abstraction: e.Abstraction, Argument: arg}, true
}
return e, false