simplify: no distinction between generic types and 'normal' types.
This commit is contained in:
parent
b4826605af
commit
a664ddac8a
27 changed files with 535 additions and 360 deletions
|
|
@ -9,10 +9,9 @@ export const SymbolByte = "Byte__bf9e8453cd554e81971880ba33dc9f27";
|
|||
export const SymbolChar = "Char__e47159519d3345119336b751fc8da1de";
|
||||
export const SymbolUnit = "Unit__a70ca021c32a4036a594d332aedfb029";
|
||||
export const SymbolBottom = "⊥__95beece951bc457781be8c5481d35dcc";
|
||||
export const SymbolSymbol = "Symbol__f67c077430e04e4fa40ed2e2b2a3040d";
|
||||
export const SymbolUUID = "UUID__f67c077430e04e4fa40ed2e2b2a3040d";
|
||||
export const SymbolType = "Type__fdbea309d66f49b483b0dd4ceb785f7d";
|
||||
export const SymbolTop = "⊤__38709c3c0039468782103256d4730d1f";
|
||||
export const SymbolGenericType = "GenericType__e9d8010b82f64206afa83d0c163df5d2";
|
||||
export const SymbolDynamic = "Dynamic__3c16c415dba94228ada37dc9d446f54f";
|
||||
|
||||
export const Int = makeTypeConstructor(SymbolInt)(0);
|
||||
|
|
@ -27,13 +26,11 @@ export const Unit = makeTypeConstructor(SymbolUnit)(0);
|
|||
// Bottom type has no instances.
|
||||
export const Bottom = makeTypeConstructor(SymbolBottom)(0);
|
||||
|
||||
export const SymbolT = makeTypeConstructor(SymbolSymbol)(0);
|
||||
export const UUID = makeTypeConstructor(SymbolUUID)(0);
|
||||
|
||||
// Types are typed by Top
|
||||
export const Type = makeTypeConstructor(SymbolType)(0);
|
||||
|
||||
export const GenericType = makeTypeConstructor(SymbolGenericType)(0);
|
||||
|
||||
// Everything is typed by Top
|
||||
export const Top = makeTypeConstructor(SymbolTop)(0);// A type-link, connecting a value to its Type.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
import { SymbolInt, SymbolT, SymbolBool, SymbolDouble, SymbolByte, SymbolChar, SymbolUnit, SymbolBottom, SymbolSymbol, SymbolType, SymbolGenericType, SymbolTop, Type, Int, Bool, Double, Byte, Char, Unit, Bottom, GenericType, Top, SymbolDynamic, Dynamic } from "./primitive_types.js";
|
||||
import { SymbolInt, UUID, SymbolBool, SymbolDouble, SymbolByte, SymbolChar, SymbolUnit, SymbolBottom, SymbolUUID, SymbolType, SymbolTop, Type, Int, Bool, Double, Byte, Char, Unit, Bottom, Top, SymbolDynamic, Dynamic } from "./primitive_types.js";
|
||||
|
||||
export const ModulePrimitiveSymbols = [
|
||||
{ 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 },
|
||||
{ i: SymbolDynamic , t: SymbolT },
|
||||
{ i: SymbolInt , t: UUID },
|
||||
{ i: SymbolBool , t: UUID },
|
||||
{ i: SymbolDouble , t: UUID },
|
||||
{ i: SymbolByte , t: UUID },
|
||||
{ i: SymbolChar , t: UUID },
|
||||
{ i: SymbolUnit , t: UUID },
|
||||
{ i: SymbolBottom , t: UUID },
|
||||
{ i: SymbolUUID , t: UUID },
|
||||
{ i: SymbolType , t: UUID },
|
||||
{ i: SymbolTop , t: UUID },
|
||||
{ i: SymbolDynamic , t: UUID },
|
||||
];
|
||||
|
||||
export const ModulePrimitiveTypes = [
|
||||
|
|
@ -23,9 +22,8 @@ export const ModulePrimitiveTypes = [
|
|||
{ i: Char , t: Type },
|
||||
{ i: Unit , t: Type },
|
||||
{ i: Bottom , t: Type },
|
||||
{ i: SymbolT , t: Type },
|
||||
{ i: UUID , t: Type },
|
||||
{ i: Type , t: Type },
|
||||
{ i: GenericType , t: Type },
|
||||
{ i: Top , t: Type },
|
||||
{ i: Dynamic , t: Type },
|
||||
];
|
||||
|
|
|
|||
43
lib/primitives/typevars.js
Normal file
43
lib/primitives/typevars.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import { makeTypeConstructor } from "../meta/type_constructor.js";
|
||||
import { memoize } from "../util/util.js";
|
||||
import { getSymbol } from "./type.js";
|
||||
|
||||
export const UNBOUND_SYMBOLS = [
|
||||
"a__00000000000000000000000000000000",
|
||||
"b__00000000000000000000000000000000",
|
||||
"c__00000000000000000000000000000000",
|
||||
"d__00000000000000000000000000000000",
|
||||
"e__00000000000000000000000000000000",
|
||||
"f__00000000000000000000000000000000",
|
||||
"g__00000000000000000000000000000000",
|
||||
"h__00000000000000000000000000000000",
|
||||
"i__00000000000000000000000000000000",
|
||||
"j__00000000000000000000000000000000",
|
||||
"k__00000000000000000000000000000000",
|
||||
"l__00000000000000000000000000000000",
|
||||
"m__00000000000000000000000000000000",
|
||||
"n__00000000000000000000000000000000",
|
||||
"o__00000000000000000000000000000000",
|
||||
"p__00000000000000000000000000000000",
|
||||
"q__00000000000000000000000000000000",
|
||||
"r__00000000000000000000000000000000",
|
||||
"s__00000000000000000000000000000000",
|
||||
"t__00000000000000000000000000000000",
|
||||
"u__00000000000000000000000000000000",
|
||||
"v__00000000000000000000000000000000",
|
||||
"w__00000000000000000000000000000000",
|
||||
"x__00000000000000000000000000000000",
|
||||
"y__00000000000000000000000000000000",
|
||||
"z__00000000000000000000000000000000",
|
||||
];
|
||||
|
||||
// Type variables are just like nominal types.
|
||||
export const TYPE_VARS = UNBOUND_SYMBOLS.map(symbol => makeTypeConstructor(symbol)(0));
|
||||
|
||||
// Turn list into Set for faster lookup.
|
||||
const unbound_set = memoize(() => new Set(UNBOUND_SYMBOLS));
|
||||
|
||||
// What makes a type variable a type variable, is its symbol occurring in the above list.
|
||||
export const isTypeVar = type => {
|
||||
return unbound_set().has(getSymbol(type));
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue