interactive prompt

This commit is contained in:
Joeri Exelmans 2025-03-23 17:46:39 +01:00
parent bc91d9bf39
commit 3596e01c28
9 changed files with 298 additions and 105 deletions

View file

@ -8,19 +8,21 @@ import { eqDictType } from "./eq_type";
export const getEq = numDict => numDict.eq;
export const ModuleEq = {l:[
...typedFnType(eqDictType, fnType => fnType({in: Type, out: Type})),
// type constructor: Type -> Type
...typedFnType(eqDictType, fnType => fnType(Type)(Type)),
...typedFnType(getEq, fnType => makeGeneric(a =>
fnType({
in: eqDictType(a),
out: fnType({
in: a,
out: fnType({
in: a,
out: Bool,
}),
}),
}))),
// (EqDict a) -> a -> a -> Bool
...typedFnType(getEq, fnType =>
makeGeneric(a =>
fnType
(eqDictType(a))
(fnType
(a)
(fnType
(a)
(Bool)
)
))),
]};
// all our data (and types) are encoded such that we can test equality the same way:

View file

@ -1,4 +1,8 @@
import { DefaultMap } from "../util.js";
const eqDictTypeRegistry = new DefaultMap(a => ({ eqDict: a }));
const eqDictSymbol = Symbol('EqDict');
const eqDictTypeRegistry = new DefaultMap(a => ({
symbol: eqDictSymbol,
params: [a],
}));
export const eqDictType = a => eqDictTypeRegistry.getdefault(a, true);

View file

@ -1,4 +1,8 @@
import { DefaultMap } from "../util.js";
const numDictTypeRegistry = new DefaultMap(a => ({ numDict: a }));
const numDictSymbol = Symbol("NumDict");
const numDictTypeRegistry = new DefaultMap(a => ({
symbol: numDictSymbol,
params: [a],
}));
export const numDictType = a => numDictTypeRegistry.getdefault(a, true);