branching and very basic merging of slots

This commit is contained in:
Joeri Exelmans 2025-04-17 09:19:41 +02:00
parent 614e6c0fdb
commit 3978f7f835
32 changed files with 684 additions and 420 deletions

View file

@ -1,6 +1,6 @@
import { constructorLeft, constructorRight } from "../structures/sum.js";
import { fnType, setType, sumType, typedFnType } from "../structures/types.js";
import { GenericType, SymbolT, Type, Unit } from "./types.js";
import { setType, sumType, typedFnType } from "../structures/types.js";
import { Any, GenericType, SymbolT, Type, Unit } from "./types.js";
import { unit } from "./unit.js";
export const getType = genericType => genericType.type;
@ -11,11 +11,11 @@ export const toNonGeneric = genericType => (genericType.typeVars.size === 0)
: constructorLeft(unit);
export const ModuleGenericType = {l:[
{i: GenericType, t: Type},
{i: GenericType, t: Any},
...typedFnType(getType, fnType => fnType(GenericType)(Type)),
// ...typedFnType(getType, fnType => fnType(GenericType)(Type)),
...typedFnType(getTypeVars, fnType => fnType(GenericType)(setType(SymbolT))),
// ...typedFnType(getTypeVars, fnType => fnType(GenericType)(setType(SymbolT))),
...typedFnType(toNonGeneric, fnType => fnType(GenericType)(sumType(Unit)(Type))),
]};

View file

@ -10,6 +10,7 @@ const SymbolChar = Symbol('Char');
const SymbolUnit = Symbol('Unit');
const SymbolSymbol = Symbol('Symbol');
const SymbolType = Symbol('Type');
const symbolAny = Symbol('Any');
const SymbolGenericType = Symbol('GenericType');
export const Int = makeTypeConstructor(SymbolInt)(0);
@ -23,10 +24,13 @@ export const Unit = makeTypeConstructor(SymbolUnit)(0);
export const SymbolT = makeTypeConstructor(SymbolSymbol)(0);
// Types are typed by Any
export const Type = makeTypeConstructor(SymbolType)(0);
export const GenericType = makeTypeConstructor(SymbolGenericType)(0);
// Everything is typed by Any
export const Any = makeTypeConstructor(symbolAny)(0);
export const ModuleSymbols = {l:[
{i: SymbolInt , t: SymbolT},
@ -39,3 +43,5 @@ export const ModuleSymbols = {l:[
{i: SymbolType , t: SymbolT},
{i: SymbolGenericType, t: SymbolT},
]};