parser for types + start moving all types to separate modules
This commit is contained in:
parent
8eec5b9239
commit
1d826ea8d4
11 changed files with 277 additions and 88 deletions
|
|
@ -1,7 +1,3 @@
|
|||
import { fnType, setType } from "./types.js";
|
||||
import { Int } from "../primitives/types.js";
|
||||
import { makeGeneric } from "../generics/generics.js";
|
||||
|
||||
import createRBTree from "functional-red-black-tree";
|
||||
import { inspect } from "node:util";
|
||||
|
||||
|
|
@ -9,6 +5,7 @@ export class RBTreeWrapper {
|
|||
constructor(tree) {
|
||||
this.tree = tree;
|
||||
}
|
||||
// pretty print to console
|
||||
[inspect.custom](depth, options, inspect) {
|
||||
const entries = [];
|
||||
this.tree.forEach((key,val) => {entries.push(`${inspect(key)} => ${inspect(val)}`);});
|
||||
|
|
@ -19,7 +16,6 @@ export class RBTreeWrapper {
|
|||
// (a -> a -> Int) -> Set(a)
|
||||
export const emptySet = compareFn => new RBTreeWrapper(createRBTree((x, y) => compareFn(x)(y)));
|
||||
|
||||
// const emptySetType = makeGeneric(a => fnType(() => fnType(a)(fnType(a)(Int)))(() => set(() => a)));
|
||||
|
||||
export const has = set => key => set.tree.get(key) === true;
|
||||
export const add = set => key => set.tree.get(key) === true ? set : new RBTreeWrapper(set.tree.insert(key, true));
|
||||
|
|
@ -42,33 +38,3 @@ export const read = iter => ifNotDone => ifDone => {
|
|||
export const forEach = set => fn => {
|
||||
set.tree.forEach(key => { fn(key); });
|
||||
};
|
||||
|
||||
export const ModuleSet = {l:[
|
||||
// // Type -> Type
|
||||
// ...typedFnType(setType, fnType =>
|
||||
// fnType
|
||||
// /* in */ (Type)
|
||||
// /* out */ (Type)
|
||||
// ),
|
||||
|
||||
// {i: emptySet , t: emptySetType},
|
||||
// {i: emptySetType, t: GenericType },
|
||||
|
||||
// ...typedFnType(has, fnType =>
|
||||
// makeGeneric(a =>
|
||||
// fnType
|
||||
// /* in */ (set(() => a))
|
||||
// /* out */ (fnType
|
||||
// /* in */ (a)
|
||||
// /* out */ (Bool)
|
||||
// )), GenericType),
|
||||
|
||||
// ...typedFnType(add, fnType =>
|
||||
// makeGeneric(a =>
|
||||
// fnType
|
||||
// /* in */ (set(() => a))
|
||||
// /* out */ (fnType
|
||||
// /* in */ (a)
|
||||
// /* out */ (set(() => a))
|
||||
// )), GenericType),
|
||||
]};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue