dope2/typed.js
2025-03-24 17:28:07 +01:00

18 lines
560 B
JavaScript

import { typedFnType } from "./structures/types.js";
import { Type } from "./primitives/types.js";
// Everything is (implicitly) typed by the Any type.
export const Any = { symbol: Symbol('Any'), params: [] };
// A type-link, connecting a value to its Type.
export const Typed = { symbol: Symbol('Typed'), params: [] };
const getInst = lnk => lnk.i;
const getType = lnk => lnk.t;
export const ModuleTyped = {l:[
{i: Typed, t: Type},
...typedFnType(getInst, fnType => fnType(Typed)(Type)),
...typedFnType(getType, fnType => fnType(Typed)(Type)),
]};