feat: copied code over

This commit is contained in:
2026-01-19 19:32:08 -05:00
parent 5f2dcc9394
commit 091bc70172
18 changed files with 1102 additions and 6 deletions

View File

@@ -0,0 +1,59 @@
package saccharine
import (
"git.maximhutz.com/max/lambda/pkg/repr"
)
type Expression interface {
repr.Repr
}
var (
_ Expression = Abstraction{}
_ Expression = Application{}
_ Expression = Variable{}
_ Expression = Clause{}
)
/** ------------------------------------------------------------------------- */
type Abstraction struct {
Parameters []string
Body Expression
}
func NewAbstraction(parameter []string, body Expression) *Abstraction {
return &Abstraction{Parameters: parameter, Body: body}
}
/** ------------------------------------------------------------------------- */
type Application struct {
Abstraction Expression
Arguments []Expression
}
func NewApplication(abstraction Expression, arguments []Expression) *Application {
return &Application{Abstraction: abstraction, Arguments: arguments}
}
/** ------------------------------------------------------------------------- */
type Variable struct {
Name string
}
func NewVariable(name string) *Variable {
return &Variable{Name: name}
}
/** ------------------------------------------------------------------------- */
type Clause struct {
Statements []Statement
Returns Expression
}
func NewClause(statements []Statement, returns Expression) *Clause {
return &Clause{Statements: statements, Returns: returns}
}