Add product and sum types
This commit is contained in:
parent
6023efc295
commit
574651ccb7
18 changed files with 209 additions and 157 deletions
|
|
@ -1,22 +1,7 @@
|
|||
import { fnType } from "../function_registry.js";
|
||||
import { fnType, getListType } from "../type_registry.js";
|
||||
import {Type, Function} from "../metacircular.js";
|
||||
import {Int} from "../primitives/symbols.js";
|
||||
|
||||
// Global store of list types:
|
||||
const listTypes = new Map();
|
||||
export function getListType(elementType) {
|
||||
if (listTypes.has(elementType)) {
|
||||
// only generate each list type once
|
||||
// this would not be necessary if we could define our own equality and hash functions on objects in JavaScript.
|
||||
return listTypes.get(elementType);
|
||||
}
|
||||
else {
|
||||
const type = Symbol('ListOf:'+elementType.toString());
|
||||
listTypes.set(elementType, type);
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
export const makeListModule = elementType => {
|
||||
// List<elementType> type depends on elementType
|
||||
// generating it another time, will give the same type (structurally equivalent):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue