aboutsummaryrefslogtreecommitdiff
path: root/src/eval.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/eval.ts')
-rw-r--r--src/eval.ts19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/eval.ts b/src/eval.ts
index fdffed7..2b93e49 100644
--- a/src/eval.ts
+++ b/src/eval.ts
@@ -6,7 +6,7 @@ import * as builtins from './eval-env/builtins'
type EffDefn = {
default: (ctx: Ctx, args: Type[]) => Record<string, () => Promise<string[]>>,
- cleanup: () => void,
+ cleanup?: () => void,
}
const mergeEffDefns = (a: EffDefn, b: EffDefn): EffDefn => ({
default: (ctx: Ctx, args: Type[]) => ({
@@ -14,13 +14,13 @@ const mergeEffDefns = (a: EffDefn, b: EffDefn): EffDefn => ({
...b.default(ctx, args),
}),
cleanup: () => {
- a.cleanup()
- b.cleanup()
+ a.cleanup?.()
+ b.cleanup?.()
},
})
-const cleanupActions = new Set<() => void>()
-export const cleanup = () => cleanupActions.forEach(f => f())
+const cleanupActions = new Set<undefined | (() => void)>()
+export const cleanup = () => cleanupActions.forEach(f => f?.())
let prevEnv: string
@@ -28,6 +28,7 @@ export const evaluateType = async (
ctx: Ctx,
effTyp: Type
): Promise<string[]> => {
+ // TODO: base type check
const name = effTyp.getSymbol()?.getName()
const args = effTyp.getTypeArguments()
@@ -67,11 +68,3 @@ export const evaluateType = async (
},
})
}
-
-export const evalList = async (ctx: Ctx, effectTyps: Type[]) => {
- const effectResults: string[] = []
- for (const item of effectTyps ?? []) {
- effectResults.push(...(await evaluateType(ctx, item)))
- }
- return effectResults
-}