rename some things
This commit is contained in:
parent
e04cac4f7d
commit
8a4bd44f04
16 changed files with 92 additions and 60 deletions
|
|
@ -2,13 +2,13 @@ import { makeCompareFn } from "../compare/registry.js";
|
|||
import { Int, Unit } from "../primitives/types.js";
|
||||
import { unit } from "../primitives/unit.js";
|
||||
import { enumType, makeConstructors, makeMatchFn } from "../structures/enum.js";
|
||||
import { constructorProduct } from "../structures/product.js";
|
||||
import { newProduct } from "../structures/product.js";
|
||||
import { lsType, prettyT } from "../structures/types.js";
|
||||
|
||||
const variants = [
|
||||
constructorProduct("price")(Int),
|
||||
constructorProduct("prices")(lsType(Int)),
|
||||
constructorProduct("not_found")(Unit),
|
||||
newProduct("price")(Int),
|
||||
newProduct("prices")(lsType(Int)),
|
||||
newProduct("not_found")(Unit),
|
||||
];
|
||||
|
||||
const myEnumType = enumType(variants);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { assign, makeGeneric, unify } from "../generics/generics.js";
|
||||
import { Bool, Int } from "../primitives/types.js";
|
||||
import { constructorLeft, constructorRight, match } from "../structures/sum.js";
|
||||
import { newLeft, newRight, match } from "../structures/sum.js";
|
||||
import { fnType, sumType } from "../structures/types.js";
|
||||
import { pretty } from '../util/pretty.js';
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ console.log(assign(
|
|||
makeGeneric(() => IntOrBool),
|
||||
));
|
||||
|
||||
console.log("calling constructorLeft with Int:");
|
||||
console.log("calling newLeft with Int:");
|
||||
const typeAtCallSite = assign(
|
||||
makeGeneric((a, b) =>
|
||||
fnType
|
||||
|
|
@ -51,10 +51,10 @@ console.log(pretty(assign(
|
|||
)));
|
||||
|
||||
console.log("valid function calls:");
|
||||
console.log(cipFunction(constructorLeft(5)));
|
||||
console.log(cipFunction(constructorLeft(7)));
|
||||
console.log(cipFunction(constructorRight(true)));
|
||||
console.log(cipFunction(newLeft(5)));
|
||||
console.log(cipFunction(newLeft(7)));
|
||||
console.log(cipFunction(newRight(true)));
|
||||
|
||||
console.log("invalid function calls:");
|
||||
console.log(cipFunction(5));
|
||||
console.log(cipFunction(constructorLeft("abc")));
|
||||
console.log(cipFunction(newLeft("abc")));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue