fix: no stringify in hot loop
This commit is contained in:
@@ -11,16 +11,14 @@ func Substitute(e *Expression, target string, replacement Expression) {
|
||||
return
|
||||
}
|
||||
|
||||
if !IsFreeVariable(typed.Parameter, replacement) {
|
||||
Substitute(&typed.Body, target, replacement)
|
||||
return
|
||||
if IsFreeVariable(typed.Parameter, replacement) {
|
||||
replacementFreeVars := GetFreeVariables(replacement)
|
||||
used := GetFreeVariables(typed.Body)
|
||||
used.Merge(replacementFreeVars)
|
||||
freshVar := GenerateFreshName(used)
|
||||
Rename(typed, typed.Parameter, freshVar)
|
||||
}
|
||||
|
||||
replacementFreeVars := GetFreeVariables(replacement)
|
||||
used := GetFreeVariables(typed.Body)
|
||||
used.Merge(replacementFreeVars)
|
||||
freshVar := GenerateFreshName(used)
|
||||
Rename(typed, typed.Parameter, freshVar)
|
||||
Substitute(&typed.Body, target, replacement)
|
||||
case *Application:
|
||||
Substitute(&typed.Abstraction, target, replacement)
|
||||
|
||||
Reference in New Issue
Block a user