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
31
structures/set.types.js
Normal file
31
structures/set.types.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { makeGeneric } from "../generics/generics.js";
|
||||
import { Int } from "../primitives/types.js";
|
||||
import { emptySet, has, add } from "./set.js";
|
||||
import { fnType, setType } from "./types.js";
|
||||
|
||||
const emptySetType = makeGeneric(a =>
|
||||
fnType
|
||||
// comparison function:
|
||||
(_ => fnType
|
||||
(_ => a)
|
||||
(_ => fnType(_ => a)(_ => Int)))
|
||||
// the set:
|
||||
(_ => setType(_ => a))
|
||||
);
|
||||
|
||||
export const ModuleSet = {
|
||||
l: [
|
||||
// Type -> Type
|
||||
...typedFnType(setType, fnType => fnType(_ => Type)(_ => Type)
|
||||
),
|
||||
|
||||
{ i: emptySet, t: emptySetType },
|
||||
{ i: emptySetType, t: GenericType },
|
||||
|
||||
...typedFnType(has, fnType => makeGeneric(a => fnType(_ => setType(_ => a))(_ => fnType(_ => a)(_ => Bool)
|
||||
)), GenericType),
|
||||
|
||||
...typedFnType(add, fnType => makeGeneric(a => fnType(setType(_ => a))(fnType(a)(setType(_ => a))
|
||||
)), GenericType),
|
||||
]
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue