dope2/structures/set.types.js

31 lines
862 B
JavaScript

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),
]
};