add versioning module
This commit is contained in:
parent
6809674406
commit
bdd7dabc90
4 changed files with 31 additions and 23 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { getDefaultTypeParser, module2Env, ModuleStd } from "dope2";
|
||||
import { getDefaultTypeParser, list, ModuleStd, trie } from "dope2";
|
||||
// import type { Dynamic, Environment } from "./eval";
|
||||
import type { StaticEnvironment } from "../../eval/infer_type";
|
||||
|
||||
|
|
@ -7,15 +7,18 @@ export const functionWith4Params = i => j => k => l => i+j+k+l;
|
|||
|
||||
const mkType = getDefaultTypeParser();
|
||||
|
||||
const mod = ModuleStd.concat([
|
||||
["true", {i: true, t: mkType("Bool")}],
|
||||
["false", {i: false, t: mkType("Bool")}],
|
||||
["leqZero", {i: n => leq => otherwise => (n<=0)?leq({}):otherwise({}), t: mkType("Int -> (Unit -> a) -> (Unit -> a) -> a")}],
|
||||
["functionWith3Params", { i: functionWith3Params, t: mkType("Int->Int->Int->Int") }],
|
||||
["functionWith4Params", { i: functionWith4Params, t: mkType("Int->Int->Int->Int->Int")}]
|
||||
]).map(([name, {i,t}]) => [name, { kind: "value", i, t, unification: new Map() }] as [string, any]);
|
||||
|
||||
export const extendedEnv: StaticEnvironment = {
|
||||
names: module2Env(ModuleStd.concat([
|
||||
["true", {i: true, t: mkType("Bool")}],
|
||||
["false", {i: false, t: mkType("Bool")}],
|
||||
["leqZero", {i: n => leq => otherwise => (n<=0)?leq({}):otherwise({}), t: mkType("Int -> (Unit -> a) -> (Unit -> a) -> a")}],
|
||||
["functionWith3Params", { i: functionWith3Params, t: mkType("Int->Int->Int->Int") }],
|
||||
["functionWith4Params", { i: functionWith4Params, t: mkType("Int->Int->Int->Int->Int")}]
|
||||
]).map(([name, {i,t}]) => [name, { kind: "value", i, t, unification: new Map() }] as [string, any])
|
||||
).name2dyn,
|
||||
// nextFreeTypeVar: 0,
|
||||
names: list.fold
|
||||
(acc => ([name, dynamic]) => trie.insert(acc)(name)(dynamic))
|
||||
(trie.emptyTrie)
|
||||
(mod),
|
||||
typevars: new Set(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export function LambdaBlock({state, setState, score, typeInfo, evalResult}: Lamb
|
|||
:: <Type type={typeInfo.paramType} />
|
||||
</div>
|
||||
|
||||
<span className="keyword">:</span>
|
||||
<span className="keyword">.</span>
|
||||
|
||||
<div className="lambdaInner">
|
||||
<ExprBlock
|
||||
|
|
@ -61,5 +61,5 @@ export function LambdaBlock({state, setState, score, typeInfo, evalResult}: Lamb
|
|||
evalResult={evalResult.inner}
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</span>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue