summaryrefslogtreecommitdiff
path: root/gock.ts
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-08-03 09:18:06 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-08-03 09:18:06 -0700
commitfc2844ae88c85f082b47630b92a55bca3ff285b1 (patch)
tree4a6cca7892459ece38bf72b61352d4fc1bb239e0 /gock.ts
downloadgock-fc2844ae88c85f082b47630b92a55bca3ff285b1.tar.gz
gock-fc2844ae88c85f082b47630b92a55bca3ff285b1.zip
Init
Diffstat (limited to 'gock.ts')
-rw-r--r--gock.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/gock.ts b/gock.ts
new file mode 100644
index 0000000..e8d1c53
--- /dev/null
+++ b/gock.ts
@@ -0,0 +1,42 @@
+type Int = "Int";
+type Bool = "Bool";
+type Atom = Int | Bool;
+type SimpleType = Arrow | Atom;
+type Arrow = {
+ left: SimpleType;
+ right: SimpleType;
+};
+
+type Identifier = string;
+
+type Binding = {
+ name: Identifier;
+ type?: SimpleType;
+};
+
+type Abstraction = {
+ binding: Binding;
+ body: ASTNode;
+};
+
+type ASTNode = Abstraction | Application | Identifier;
+
+//
+
+class Environment<T> {
+ constructor(private readonly _captures: Map<Identifier, T>, private readonly _parent?: Environment) {}
+
+ public add(identifier: Identifier, substitution: T): Environment<T> {
+ const captures = new HashMap(); captures.put(identifier, substitution);
+ return new Environment<>(captures, this);
+ }
+
+ public get(identifier: Identifier): T? {
+ if (this._captures.has(identifier)) return this._captures.get(identifier);
+ return this._parent?.get(identifier);
+ }
+}
+
+//const tokenize
+// const parse
+// const check