fix things

This commit is contained in:
Joeri Exelmans 2025-05-08 23:08:48 +02:00
parent 8a4b47df02
commit 4c394441b0
2 changed files with 7 additions and 6 deletions

View file

@ -4,7 +4,7 @@ import { unit } from "../lib/primitives/unit.js";
import { makeConstructors, makeMatchFn } from "../lib/structures/enum.js"; import { makeConstructors, makeMatchFn } from "../lib/structures/enum.js";
import { enumType } from "../lib/structures/enum.types.js"; import { enumType } from "../lib/structures/enum.types.js";
import { newProduct } from "../lib/structures/product.js"; import { newProduct } from "../lib/structures/product.js";
import { lsType } from "../lib/structures/type_constructors.js"; import { lsType } from "../lib/structures/type_constructors.types.js";
import { prettyT } from "../lib/util/pretty.js"; import { prettyT } from "../lib/util/pretty.js";
Error.stackTraceLimit = Infinity; Error.stackTraceLimit = Infinity;
@ -15,10 +15,10 @@ const variants = [
newProduct("not_found")(_ => Unit), newProduct("not_found")(_ => Unit),
]; ];
const compatibleNestedSumType = enumType(variants); const structuralType = enumType(variants);
console.log("observe the type that was generated:"); console.log("observe the type that was generated:");
console.log(" ", prettyT(compatibleNestedSumType)); console.log(" ", prettyT(structuralType));
const [newPrice, newPrices, newNotFound] = makeConstructors(variants); const [newPrice, newPrices, newNotFound] = makeConstructors(variants);
@ -41,7 +41,7 @@ console.log(" ", myEnumToString(price));
console.log(" ", myEnumToString(prices)); console.log(" ", myEnumToString(prices));
console.log(" ", myEnumToString(notFound)); console.log(" ", myEnumToString(notFound));
const compareMyEnum = makeCompareFn(compatibleNestedSumType); const compareMyEnum = makeCompareFn(structuralType);
console.log("observe the generated compare function in action:"); console.log("observe the generated compare function in action:");
console.log(" should be smaller ->", compareMyEnum(price)(prices)); console.log(" should be smaller ->", compareMyEnum(price)(prices));

View file

@ -1,10 +1,10 @@
import { makeCompareFn } from "../compare/dynamic.js"; import { makeCompareFn } from "../compare/dynamic.js";
import { makeGeneric } from "../generics/generics.js"; import { makeGeneric } from "../generics/generics.js";
import { newDynamic } from "../primitives/dynamic.js"; import { newDynamic } from "../primitives/dynamic.js";
import { Bottom, Type } from "../primitives/primitive_types.js"; import { Bottom } from "../primitives/primitive_types.js";
import { makeConstructors, makeMatchFn } from "./enum.js"; import { makeConstructors, makeMatchFn } from "./enum.js";
import { getRight } from "./product.js"; import { getRight } from "./product.js";
import { fnType, sumType } from "./type_constructors.js"; import { fnType, sumType } from "./type_constructors.types.js";
// 'variants' is an array of (name: string, type: Type) pairs. // 'variants' is an array of (name: string, type: Type) pairs.
// e.g., the list of variants: // e.g., the list of variants:
@ -77,4 +77,5 @@ export const makeModuleEnum = type => variants => {
// compare-function: // compare-function:
newDynamic(makeCompareFn(enumType(variants))) newDynamic(makeCompareFn(enumType(variants)))
]; ];
return module;
} }