csci8980-f23/bidir/contexts.ts
2023-10-22 19:39:02 -05:00

18 lines
462 B
TypeScript

// Helper functions for dealing with contexts
import { ContextEntry, Type } from "./data";
import { isEqual } from "lodash";
/** Γ |- A (is the given type in this context?) */
export function isTypeInContext(type: Type, ctx: ContextEntry[]): boolean {
for (const entry of ctx) {
switch (entry.kind) {
case "termAnnot":
if (isEqual(entry.type, type)) return true;
break;
default:
continue;
}
}
return false;
}