@@ -15,68 +15,60 @@ import {
1515
1616const debug = false
1717
18- export function equalInCtx ( ctx : Ctx , left : Value , right : Value ) : boolean {
18+ export function equalInCtx ( ctx : Ctx , lhs : Value , rhs : Value ) : boolean {
1919 ctx = ctxDepthAdd1 ( ctx )
2020
21- left = Values . lazyActiveDeep ( left )
22- right = Values . lazyActiveDeep ( right )
21+ lhs = Values . lazyActiveDeep ( lhs )
22+ rhs = Values . lazyActiveDeep ( rhs )
2323
2424 if ( debug ) {
25- console . log ( "[equalInCtx]" , ctx . depth , " " , formatValue ( left ) )
26- console . log ( "[equalInCtx]" , ctx . depth , "=" , formatValue ( right ) )
27- console . log ( "[equalInCtx]" , "same:" , same ( left , right ) )
25+ console . log ( "[equalInCtx]" , ctx . depth , " " , formatValue ( lhs ) )
26+ console . log ( "[equalInCtx]" , ctx . depth , "=" , formatValue ( rhs ) )
27+ console . log ( "[equalInCtx]" , "same:" , same ( lhs , rhs ) )
2828 }
2929
30- if ( same ( left , right ) ) return true
30+ if ( same ( lhs , rhs ) ) return true
3131
32- if ( left . kind === "NotYet" && right . kind === "NotYet" ) {
33- return equalNeutralInCtx ( ctx , left . neutral , right . neutral )
32+ if ( lhs . kind === "NotYet" && rhs . kind === "NotYet" ) {
33+ return equalNeutralInCtx ( ctx , lhs . neutral , rhs . neutral )
3434 }
3535
36- if ( left . kind === "Lambda" ) {
37- if ( lambdaIsDefined ( left ) ) {
38- if ( ctxBlazeOccurred ( ctx , left , right ) ) {
36+ if ( lhs . kind === "Lambda" ) {
37+ if ( lambdaIsDefined ( lhs ) ) {
38+ if ( ctxBlazeOccurred ( ctx , lhs , rhs ) ) {
3939 return true
4040 } else {
41- ctx = ctxBlazeTrail ( ctx , left , right )
41+ ctx = ctxBlazeTrail ( ctx , lhs , rhs )
4242 }
4343 }
4444
45- const freshName = freshen ( ctx . boundNames , left . name )
45+ const freshName = freshen ( ctx . boundNames , lhs . name )
4646 ctx = ctxBindName ( ctx , freshName )
4747 const v = Neutrals . Var ( freshName )
4848 const arg = Values . NotYet ( v )
49- return equalInCtx (
50- ctx ,
51- applyWithDelay ( left , arg ) ,
52- applyWithDelay ( right , arg ) ,
53- )
49+ return equalInCtx ( ctx , applyWithDelay ( lhs , arg ) , applyWithDelay ( rhs , arg ) )
5450 }
5551
56- if ( right . kind === "Lambda" ) {
57- if ( lambdaIsDefined ( right ) ) {
58- if ( ctxBlazeOccurred ( ctx , right , left ) ) {
52+ if ( rhs . kind === "Lambda" ) {
53+ if ( lambdaIsDefined ( rhs ) ) {
54+ if ( ctxBlazeOccurred ( ctx , rhs , lhs ) ) {
5955 return true
6056 } else {
61- ctx = ctxBlazeTrail ( ctx , right , left )
57+ ctx = ctxBlazeTrail ( ctx , rhs , lhs )
6258 }
6359 }
6460
65- const freshName = freshen ( ctx . boundNames , right . name )
61+ const freshName = freshen ( ctx . boundNames , rhs . name )
6662 ctx = ctxBindName ( ctx , freshName )
6763 const v = Neutrals . Var ( freshName )
6864 const arg = Values . NotYet ( v )
69- return equalInCtx (
70- ctx ,
71- applyWithDelay ( left , arg ) ,
72- applyWithDelay ( right , arg ) ,
73- )
65+ return equalInCtx ( ctx , applyWithDelay ( lhs , arg ) , applyWithDelay ( rhs , arg ) )
7466 }
7567
76- if ( left . kind === "DelayedApply" && right . kind === "DelayedApply" ) {
68+ if ( lhs . kind === "DelayedApply" && rhs . kind === "DelayedApply" ) {
7769 if (
78- equalInCtx ( ctx , left . target , right . target ) &&
79- equalInCtx ( ctx , left . arg , right . arg )
70+ equalInCtx ( ctx , lhs . target , rhs . target ) &&
71+ equalInCtx ( ctx , lhs . arg , rhs . arg )
8072 ) {
8173 return true
8274 }
@@ -94,12 +86,12 @@ export function equalInCtx(ctx: Ctx, left: Value, right: Value): boolean {
9486 // }
9587 }
9688
97- if ( left . kind === "DelayedApply" ) {
98- return equalInCtx ( ctx , applyWithDelay ( left . target , left . arg ) , right )
89+ if ( lhs . kind === "DelayedApply" ) {
90+ return equalInCtx ( ctx , applyWithDelay ( lhs . target , lhs . arg ) , rhs )
9991 }
10092
101- if ( right . kind === "DelayedApply" ) {
102- return equalInCtx ( ctx , left , applyWithDelay ( right . target , right . arg ) )
93+ if ( rhs . kind === "DelayedApply" ) {
94+ return equalInCtx ( ctx , lhs , applyWithDelay ( rhs . target , rhs . arg ) )
10395 }
10496
10597 return false
0 commit comments