Allow lambda expressions without explicit paren

This commit is contained in:
2025-01-26 08:52:28 -06:00
committed by James Eversole
parent 6713b05872
commit b0b0fb22b9
9 changed files with 63 additions and 87 deletions

View File

@ -54,8 +54,6 @@ evalAST env term
(errorWithoutStackTrace $ "Variable " ++ name ++ " not defined")
name env
-- https://github.com/barry-jay-personal/typed_tree_calculus/blob/main/typed_program_analysis.pdf
-- Chapter 4: Lambda-Abstraction
elimLambda :: TricuAST -> TricuAST
elimLambda = go
where
@ -68,9 +66,9 @@ elimLambda = go
where
triageBody =
(SApp (SApp TLeaf (SApp (SApp TLeaf (SVar a)) (SVar b))) (SVar c))
-- Compose optimization
-- Composition optimization
go (SLambda [f] (SLambda [g] (SLambda [x] body)))
| body == composeBody = _COMPOSE
| body == composeBody = _COMPOSE
where
composeBody = SApp (SVar f) (SApp (SVar g) (SVar x))
-- General elimination