Eliminate redundant eager calls of elimLambda
This commit is contained in:
parent
b385349197
commit
eeaf9e0289
13
src/Eval.hs
13
src/Eval.hs
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user