style: moved functions around

This commit is contained in:
2025-12-30 15:58:14 -05:00
parent 412d3924eb
commit 2499921679
10 changed files with 115 additions and 93 deletions

View File

@@ -0,0 +1,49 @@
package saccharine
type Expression interface {
IsExpression()
}
/** ------------------------------------------------------------------------- */
type Abstraction struct {
Parameters []string
Body Expression
}
type Application struct {
Abstraction Expression
Arguments []Expression
}
type Atom struct {
Name string
}
type Clause struct {
Statements []Statement
Returns Expression
}
func (Abstraction) IsExpression() {}
func (Application) IsExpression() {}
func (Atom) IsExpression() {}
func (Clause) IsExpression() {}
/** ------------------------------------------------------------------------- */
func NewAbstraction(parameter []string, body Expression) *Abstraction {
return &Abstraction{Parameters: parameter, Body: body}
}
func NewApplication(abstraction Expression, arguments []Expression) *Application {
return &Application{Abstraction: abstraction, Arguments: arguments}
}
func NewAtom(name string) *Atom {
return &Atom{Name: name}
}
func NewClause(statements []Statement, returns Expression) *Clause {
return &Clause{Statements: statements, Returns: returns}
}