## 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>
21 lines
897 B
Go
21 lines
897 B
Go
// Package codec defines processes to convert between different representations
|
|
// of lambda calculus, and serialize the different representations.
|
|
package codec
|
|
|
|
// A Conversion is a function that turns one representation into another.
|
|
// Returns an error if the input expression cannot be converted.
|
|
type Conversion[T, U any] = func(T) (U, error)
|
|
|
|
// A Codec is an object that can serialize/deserialize one type of
|
|
// representation. It is assumed that for any x ∋ T, Decode(Encode(x)) = x.
|
|
type Codec[T any] interface {
|
|
// Encode takes an expression, and returns its serialized format, as a
|
|
// string. Returns an error if the expression cannot be serialized.
|
|
Encode(T) (string, error)
|
|
|
|
// Decode takes the serialized format of an expression, and returns its true
|
|
// value. Returns an error if the string doesn't correctly represent any
|
|
// valid expression.
|
|
Decode(string) (T, error)
|
|
}
|