progress and some refactoring
This commit is contained in:
parent
d236eca5e5
commit
d8ca2f3999
25 changed files with 376 additions and 163 deletions
38
structures/set.js
Normal file
38
structures/set.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { setType, typedFnType } from "./types.js";
|
||||
import { Bool, Type } from "../primitives/types.js";
|
||||
import { makeGeneric } from "../generics/generics.js";
|
||||
|
||||
// 'normal' implementation
|
||||
const emptySet = new Set();
|
||||
const has = set => elem => set.has(elem);
|
||||
const add = set => elem => new Set([...set, elem]);
|
||||
|
||||
export const ModuleList = {l:[
|
||||
// Type -> Type
|
||||
...typedFnType(setType, fnType =>
|
||||
fnType
|
||||
/* in */ (Type)
|
||||
/* out */ (Type)
|
||||
),
|
||||
|
||||
{i: emptySet, t: makeGeneric(a => setType(a))},
|
||||
|
||||
...typedFnType(has, fnType =>
|
||||
makeGeneric(a =>
|
||||
fnType
|
||||
/* in */ (setType(a))
|
||||
/* out */ (fnType
|
||||
/* in */ (a)
|
||||
/* out */ (Bool)
|
||||
))),
|
||||
|
||||
...typedFnType(add, fnType =>
|
||||
makeGeneric(a =>
|
||||
fnType
|
||||
/* in */ (setType(a))
|
||||
/* out */ (fnType
|
||||
/* in */ (a)
|
||||
/* out */ (setType(a))
|
||||
))),
|
||||
|
||||
]};
|
||||
Loading…
Add table
Add a link
Reference in a new issue