recursive types (and operations on them, like pretty-printing, comparison and unification) seem to be working.
big part of the code base still needs to be 'ported' to the updated type constructors.
This commit is contained in:
parent
55c5d7cffa
commit
8eec5b9239
34 changed files with 523 additions and 295 deletions
|
|
@ -11,5 +11,5 @@ export const ModuleBool = {l:[
|
|||
{i: Bool , t: Type},
|
||||
|
||||
// Bool -> Bool -> Bool
|
||||
...typedFnType(eqBool, fnType => fnType(Bool)(fnType(Bool)(Bool))),
|
||||
...typedFnType(eqBool, fnType => fnType(() => Bool)(fnType(Bool)(() => Bool))),
|
||||
]};
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ const eqByte = x => y => x === y;
|
|||
export const ModuleByte = {l:[
|
||||
{i: Byte , t: Type },
|
||||
|
||||
...typedFnType(eqByte, fnType => fnType(Byte)(fnType(Byte)(Bool))),
|
||||
...typedFnType(eqByte, fnType => fnType(() => Byte)(fnType(Byte)(() => Bool))),
|
||||
]};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export const eqDouble = x => y => x === y;
|
|||
export const ModuleDouble = {l:[
|
||||
{i: Double, t: Type},
|
||||
|
||||
...typedFnType(addDouble, fnType => fnType(Double)(fnType(Double)(Double))),
|
||||
...typedFnType(mulDouble, fnType => fnType(Double)(fnType(Double)(Double))),
|
||||
...typedFnType(eqDouble, fnType => fnType(Double)(fnType(Double)(Bool))),
|
||||
...typedFnType(addDouble, fnType => fnType(() => Double)(fnType(Double)(() => Double))),
|
||||
...typedFnType(mulDouble, fnType => fnType(() => Double)(fnType(Double)(() => Double))),
|
||||
...typedFnType(eqDouble, fnType => fnType(() => Double)(fnType(Double)(() => Bool))),
|
||||
]};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { typedFnType } from "../structures/types.js";
|
||||
import { Any, Type } from "./types.js";
|
||||
import { Top, Type } from "./types.js";
|
||||
import { makeTypeConstructor } from "../type_constructor.js";
|
||||
|
||||
// A type-link, connecting a value to its Type.
|
||||
|
|
@ -11,9 +11,9 @@ export const getType = lnk => lnk.t;
|
|||
|
||||
export const ModuleDynamic = {l:[
|
||||
{i: Dynamic, t: Type},
|
||||
{i: Any , t: Type},
|
||||
{i: Top , t: Type},
|
||||
|
||||
...typedFnType(getInst, fnType => fnType(Dynamic)(Any)),
|
||||
...typedFnType(getType, fnType => fnType(Dynamic)(Any)),
|
||||
...typedFnType(getInst, fnType => fnType(() => Dynamic)(() => Top)),
|
||||
...typedFnType(getType, fnType => fnType(() => Dynamic)(() => Top)),
|
||||
]};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { newLeft, newRight } from "../structures/sum.js";
|
||||
import { setType, sumType, typedFnType } from "../structures/types.js";
|
||||
import { Any, GenericType, SymbolT, Type, Unit } from "./types.js";
|
||||
import { Top, 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)
|
|||
: newLeft(unit);
|
||||
|
||||
export const ModuleGenericType = {l:[
|
||||
{i: GenericType, t: Any},
|
||||
{i: GenericType, t: Top},
|
||||
|
||||
// ...typedFnType(getType, fnType => fnType(GenericType)(Type)),
|
||||
// ...typedFnType(getType, fnType => fnType(() => GenericType)(() => Type)),
|
||||
|
||||
// ...typedFnType(getTypeVars, fnType => fnType(GenericType)(setType(SymbolT))),
|
||||
// ...typedFnType(getTypeVars, fnType => fnType(() => GenericType)(() => set(() => SymbolT))),
|
||||
|
||||
...typedFnType(toNonGeneric, fnType => fnType(GenericType)(sumType(Unit)(Type))),
|
||||
...typedFnType(toNonGeneric, fnType => fnType(() => GenericType)(sumType(() => Unit)(() => () => Type))),
|
||||
]};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const deserialize = str => BigInt(str);
|
|||
export const ModuleInt = {l:[
|
||||
{i: Int , t: Type },
|
||||
|
||||
...typedFnType(addInt, fnType => fnType(Int)(fnType(Int)(Int))),
|
||||
...typedFnType(mulInt, fnType => fnType(Int)(fnType(Int)(Int))),
|
||||
...typedFnType(eqInt , fnType => fnType(Int)(fnType(Int)(Bool))),
|
||||
...typedFnType(addInt, fnType => fnType(() => Int)(fnType(Int)(() => Int))),
|
||||
...typedFnType(mulInt, fnType => fnType(() => Int)(fnType(Int)(() => Int))),
|
||||
...typedFnType(eqInt , fnType => fnType(() => Int)(fnType(Int)(() => Bool))),
|
||||
]};
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ export const ModuleType = {l:[
|
|||
(Bool)
|
||||
)),
|
||||
|
||||
...typedFnType(getSymbol, fnType => fnType(Type)(SymbolT)),
|
||||
...typedFnType(getParams, fnType => fnType(Type)(lsType(Type))),
|
||||
...typedFnType(getSymbol, fnType => fnType(() => Type)(() => SymbolT)),
|
||||
...typedFnType(getParams, fnType => fnType(() => Type)(() => lsType(() =>Type))),
|
||||
|
||||
...typedFnType(isFunction, fnType => fnType(Type)(Bool)),
|
||||
...typedFnType(isFunction, fnType => fnType(() => Type)(() => Bool)),
|
||||
]};
|
||||
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
import { makeTypeConstructor } from "../type_constructor.js";
|
||||
|
||||
export const SymbolInt = Symbol('Int');
|
||||
export const SymbolBool = Symbol('Bool');
|
||||
export const SymbolDouble = Symbol('Double');
|
||||
export const SymbolByte = Symbol('Byte');
|
||||
export const SymbolChar = Symbol('Char');
|
||||
export const SymbolUnit = Symbol('Unit');
|
||||
export const SymbolBottom = Symbol('⊥');
|
||||
export const SymbolSymbol = Symbol('Symbol');
|
||||
export const SymbolType = Symbol('Type');
|
||||
export const symbolAny = Symbol('Any');
|
||||
export const SymbolInt = Symbol('Int');
|
||||
export const SymbolBool = Symbol('Bool');
|
||||
export const SymbolDouble = Symbol('Double');
|
||||
export const SymbolByte = Symbol('Byte');
|
||||
export const SymbolChar = Symbol('Char');
|
||||
export const SymbolUnit = Symbol('Unit');
|
||||
export const SymbolBottom = Symbol('⊥');
|
||||
export const SymbolSymbol = Symbol('Symbol');
|
||||
export const SymbolType = Symbol('Type');
|
||||
export const symbolTop = Symbol('⊤');
|
||||
export const SymbolGenericType = Symbol('GenericType');
|
||||
|
||||
export const Int = makeTypeConstructor(SymbolInt)(0);
|
||||
|
|
@ -28,23 +28,24 @@ export const Bottom = makeTypeConstructor(SymbolBottom)(0);
|
|||
|
||||
export const SymbolT = makeTypeConstructor(SymbolSymbol)(0);
|
||||
|
||||
// Types are typed by Any
|
||||
// Types are typed by Top
|
||||
export const Type = makeTypeConstructor(SymbolType)(0);
|
||||
|
||||
export const GenericType = makeTypeConstructor(SymbolGenericType)(0);
|
||||
|
||||
// Everything is typed by Any
|
||||
export const Any = makeTypeConstructor(symbolAny)(0);
|
||||
// Everything is typed by Top
|
||||
export const Top = makeTypeConstructor(symbolTop)(0);
|
||||
|
||||
export const ModuleSymbols = {l:[
|
||||
{i: SymbolInt , t: SymbolT},
|
||||
{i: SymbolBool , t: SymbolT},
|
||||
{i: SymbolDouble, t: SymbolT},
|
||||
{i: SymbolByte , t: SymbolT},
|
||||
{i: SymbolChar , t: SymbolT},
|
||||
{i: SymbolUnit , t: SymbolT},
|
||||
{i: SymbolBottom, t: SymbolT},
|
||||
{i: SymbolSymbol, t: SymbolT},
|
||||
{i: SymbolType , t: SymbolT},
|
||||
{i: SymbolInt , t: SymbolT},
|
||||
{i: SymbolBool , t: SymbolT},
|
||||
{i: SymbolDouble , t: SymbolT},
|
||||
{i: SymbolByte , t: SymbolT},
|
||||
{i: SymbolChar , t: SymbolT},
|
||||
{i: SymbolUnit , t: SymbolT},
|
||||
{i: SymbolBottom , t: SymbolT},
|
||||
{i: SymbolSymbol , t: SymbolT},
|
||||
{i: SymbolType , t: SymbolT},
|
||||
{i: SymbolGenericType, t: SymbolT},
|
||||
{i: symbolTop , t: SymbolT},
|
||||
]};
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ export const ModuleUnit = {l:[
|
|||
{i: Unit, t: Type},
|
||||
|
||||
// Unit -> Unit -> Bool
|
||||
...typedFnType(eqUnit, fnType => fnType(Unit)(fnType(Unit)(Bool))),
|
||||
...typedFnType(eqUnit, fnType => fnType(() => Unit)(fnType(Unit)(() => Bool))),
|
||||
]};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue