Eliminate redundant eager calls of elimLambda

This commit is contained in:
James Eversole 2025-01-20 16:05:06 -06:00 committed by James Eversole
parent b385349197
commit eeaf9e0289

View File

@ -56,18 +56,15 @@ elimLambda = go
go (SLambda (v:vs) body)
| null vs = toSKI v (elimLambda body)
| otherwise = elimLambda (SLambda [v] (SLambda vs body))
go (SApp f g ) = SApp (elimLambda f) (elimLambda g)
go (TStem t ) = TStem (elimLambda t)
go (TFork l r ) = TFork (elimLambda l) (elimLambda r)
go (SList x ) = SList (map elimLambda x)
go (SApp f g) = SApp (elimLambda f) (elimLambda g)
go x = x
toSKI x (SVar y)
| x == y = _I
| otherwise = SApp _K (SVar y)
| x == y = _I
| otherwise = SApp _K (SVar y)
toSKI x t@(SApp n u)
| not (isFree x t) = SApp _K (SApp (elimLambda n) (elimLambda u))
| otherwise = SApp (SApp _S (toSKI x (elimLambda n))) (toSKI x (elimLambda u))
| not (isFree x t) = SApp _K t
| otherwise = SApp (SApp _S (toSKI x n)) (toSKI x u)
toSKI x t
| not (isFree x t) = SApp _K t
| otherwise = SApp (SApp _S (toSKI x t)) TLeaf