progress and some refactoring
This commit is contained in:
parent
d236eca5e5
commit
d8ca2f3999
25 changed files with 376 additions and 163 deletions
8
primitives/symbol.js
Normal file
8
primitives/symbol.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// 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);
|
||||
|
||||
export const getName = symbol => symbol.description;
|
||||
|
||||
export const eqSymbol = a => b => a === b;
|
||||
|
|
@ -1,9 +1,17 @@
|
|||
// to break up dependency cycles, primitive types are defined in their own JS module
|
||||
|
||||
export const Int = { symbol: Symbol('Int') , params: [] };
|
||||
export const Bool = { symbol: Symbol('Bool') , params: [] };
|
||||
export const Double = { symbol: Symbol('Double'), params: [] };
|
||||
export const Byte = { symbol: Symbol('Byte') , params: [] };
|
||||
export const Char = { symbol: Symbol('Char') , params: [] };
|
||||
import { makeTypeConstructor } from "../type_constructor.js";
|
||||
import { constructSymbol } from "./symbol.js";
|
||||
|
||||
export const Type = { symbol: Symbol('Type'), params: [] };
|
||||
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);
|
||||
|
||||
// Unit type has only 1 instance, the empty tuple.
|
||||
export const Unit = makeTypeConstructor(constructSymbol('Unit'), 0);
|
||||
|
||||
export const SymbolT = makeTypeConstructor(constructSymbol('Symbol'), 0);
|
||||
|
||||
export const Type = makeTypeConstructor(constructSymbol('Type'), 0);
|
||||
|
|
|
|||
13
primitives/unit.js
Normal file
13
primitives/unit.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { typedFnType } from "../structures/types.js";
|
||||
import { Bool, Type, Unit } from "./types.js";
|
||||
|
||||
const eqUnit = x => y => x === y;
|
||||
|
||||
export const ModuleUnit = {l:[
|
||||
{i: {}, t: Unit},
|
||||
|
||||
{i: Unit, t: Type},
|
||||
|
||||
// Unit -> Unit -> Bool
|
||||
...typedFnType(eqUnit, fnType => fnType(Unit)(fnType(Unit)(Bool))),
|
||||
]};
|
||||
Loading…
Add table
Add a link
Reference in a new issue