dope2-webapp/src/EnvContext.ts

20 lines
No EOL
815 B
TypeScript

import { createContext } from "react";
import { getDefaultTypeParser, module2Env, ModuleStd } from "dope2";
import type { Dynamic, Environment } from "./eval";
export const functionWith3Params = i => j => k => i+j+k;
export const functionWith4Params = i => j => k => l => i+j+k+l;
const mkType = getDefaultTypeParser();
export const extendedEnv: Environment = {
names: module2Env(ModuleStd.concat([
["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, Dynamic])
).name2dyn,
nextFreeTypeVar: 0,
typeVars: new Set(),
};
export const EnvContext = createContext(extendedEnv);