rename some things
This commit is contained in:
parent
e04cac4f7d
commit
8a4bd44f04
16 changed files with 92 additions and 60 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { getInst, getType } from "../primitives/dynamic.js";
|
||||
import { SymbolBool, SymbolChar, SymbolDouble, SymbolInt, SymbolType, SymbolUnit } from "../primitives/types.js";
|
||||
import { symbolList, symbolProduct, symbolSet, symbolSum } from "../structures/types.js";
|
||||
import { compareBools, compareNumbers, compareStrings, compareUnits } from "./primitives.js";
|
||||
|
|
@ -17,11 +18,15 @@ const typeSymbolToCmp = new Map([
|
|||
[symbolProduct, compareProducts],
|
||||
[symbolSum , compareSums],
|
||||
[symbolSet , compareSets],
|
||||
])
|
||||
]);
|
||||
|
||||
export const makeCompareFn = type => {
|
||||
return type.params.reduce(
|
||||
(acc, cur) => acc(makeCompareFn(cur)),
|
||||
typeSymbolToCmp.get(type.symbol)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const compareDynamic = x => y =>
|
||||
compareTypes(getType(x))(getType(y))
|
||||
|| makeCompareFn(getType(x))(getInst(x))(getInst(y));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue