Skip to content

Commit be969d5

Browse files
committed
up
1 parent 71e4ec0 commit be969d5

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

TODO.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
`sameInCtx` -- use head on `DelayedApply`, but only for `DefinedLambda` in equal's context
2+
13
# lazy evaluation
24

35
we still can bring back lazy evaluation by lazy + box,

src/lang/equal/Ctx.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { same } from "../same/index.ts"
2-
import { type Value } from "../value/index.ts"
2+
import { type DefinedLambda, type Value } from "../value/index.ts"
33

44
export type Blaze = {
5-
lhs: Value
5+
lhs: DefinedLambda
66
rhs: Value
77
}
88

@@ -34,14 +34,18 @@ export function ctxBindName(ctx: Ctx, name: string): Ctx {
3434
}
3535
}
3636

37-
export function ctxBlazeTrail(ctx: Ctx, lhs: Value, rhs: Value): Ctx {
37+
export function ctxBlazeTrail(ctx: Ctx, lhs: DefinedLambda, rhs: Value): Ctx {
3838
return {
3939
...ctx,
4040
trail: [...ctx.trail, { lhs, rhs }],
4141
}
4242
}
4343

44-
export function ctxBlazeOccurred(ctx: Ctx, lhs: Value, rhs: Value): boolean {
44+
export function ctxBlazeOccurred(
45+
ctx: Ctx,
46+
lhs: DefinedLambda,
47+
rhs: Value,
48+
): boolean {
4549
for (const blaze of ctx.trail) {
4650
if (same(lhs, blaze.lhs) && same(rhs, blaze.rhs)) {
4751
return true

src/lang/value/lambdaUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type Lambda } from "./Value.ts"
22

3-
type DefinedLambda = Lambda & { definedName: string }
3+
export type DefinedLambda = Lambda & { definedName: string }
44

55
export function lambdaIsDefined(lambda: Lambda): lambda is DefinedLambda {
66
return lambda.definedName !== undefined

0 commit comments

Comments
 (0)