add nominal types for 2D points
This commit is contained in:
parent
94efde3e65
commit
18b5e56ff0
6 changed files with 110 additions and 21 deletions
|
|
@ -15,6 +15,7 @@ export const makeGeneric = callback => {
|
|||
};
|
||||
};
|
||||
|
||||
// From the given set of type variables, return only those that occur in the given type.
|
||||
const occurring = (type, typeVars) => {
|
||||
if (typeVars.has(type)) {
|
||||
return new Set([type]);
|
||||
|
|
@ -36,7 +37,8 @@ const occurring = (type, typeVars) => {
|
|||
|
||||
// merge {i: [1], t: List_of_Int} ->
|
||||
|
||||
|
||||
// Thanks to Hans for pointing out that this algorithm exactly like "Unification" in Prolog:
|
||||
// https://www.dai.ed.ac.uk/groups/ssp/bookpages/quickprolog/node12.html
|
||||
export const matchGeneric = (
|
||||
{typeVars: formalTypeVars, type: formalType},
|
||||
{typeVars: actualTypeVars, type: actualType},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue