dope2/typed.js

18 lines
568 B
JavaScript

import { typedFnType } from "./structures/types.js";
import { Any, Type } from "./primitives/types.js";
import { makeTypeConstructor } from "./type_constructor.js";
// A type-link, connecting a value to its Type.
const symbolTyped = Symbol('Typed');
export const Typed = makeTypeConstructor(symbolTyped)(0);
const getInst = lnk => lnk.i;
const getType = lnk => lnk.t;
export const ModuleTyped = {l:[
{i: Typed, t: Type},
{i: Any , t: Type},
...typedFnType(getInst, fnType => fnType(Typed)(Any)),
...typedFnType(getType, fnType => fnType(Typed)(Any)),
]};