turn the function for creating new types (or type constructors) into a DOPE function
This commit is contained in:
parent
d8ca2f3999
commit
a0e3aa0cb3
12 changed files with 112 additions and 58 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// The functions are only defined here. For their types, see lib/symbol.js
|
||||
|
||||
// The point of having an explicit constructor for SymbolT, is that we can later swap it out for something that is (de-)serializable.
|
||||
export const constructSymbol = name => Symbol(name);
|
||||
// Cannot turn the constructor into a DOPE function, because it is NOT PURE:
|
||||
// export const constructSymbol = name => Symbol(name);
|
||||
|
||||
export const getName = symbol => symbol.description;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,37 @@
|
|||
// to break up dependency cycles, primitive types are defined in their own JS module
|
||||
|
||||
import { makeTypeConstructor } from "../type_constructor.js";
|
||||
import { constructSymbol } from "./symbol.js";
|
||||
|
||||
export const Int = makeTypeConstructor(constructSymbol('Int'), 0);
|
||||
export const Bool = makeTypeConstructor(constructSymbol('Bool'), 0);
|
||||
export const Double = makeTypeConstructor(constructSymbol('Double'), 0);
|
||||
export const Byte = makeTypeConstructor(constructSymbol('Byte'), 0);
|
||||
export const Char = makeTypeConstructor(constructSymbol('Char'), 0);
|
||||
const SymbolInt = Symbol('Int');
|
||||
const SymbolBool = Symbol('Bool');
|
||||
const SymbolDouble = Symbol('Double');
|
||||
const SymbolByte = Symbol('Byte');
|
||||
const SymbolChar = Symbol('Char');
|
||||
const SymbolUnit = Symbol('Unit');
|
||||
const SymbolSymbol = Symbol('Symbol');
|
||||
const SymbolType = Symbol('Type');
|
||||
|
||||
export const Int = makeTypeConstructor(SymbolInt)(0);
|
||||
export const Bool = makeTypeConstructor(SymbolBool)(0);
|
||||
export const Double = makeTypeConstructor(SymbolDouble)(0);
|
||||
export const Byte = makeTypeConstructor(SymbolByte)(0);
|
||||
export const Char = makeTypeConstructor(SymbolChar)(0);
|
||||
|
||||
// Unit type has only 1 instance, the empty tuple.
|
||||
export const Unit = makeTypeConstructor(constructSymbol('Unit'), 0);
|
||||
export const Unit = makeTypeConstructor(SymbolUnit)(0);
|
||||
|
||||
export const SymbolT = makeTypeConstructor(constructSymbol('Symbol'), 0);
|
||||
export const SymbolT = makeTypeConstructor(SymbolSymbol)(0);
|
||||
|
||||
export const Type = makeTypeConstructor(constructSymbol('Type'), 0);
|
||||
export const Type = makeTypeConstructor(SymbolType)(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: SymbolSymbol, t: SymbolT},
|
||||
{i: SymbolType , t: SymbolT},
|
||||
]};
|
||||
Loading…
Add table
Add a link
Reference in a new issue