diff --git a/examples/enum.js b/examples/enum.js index d58da5d..2bb94bd 100644 --- a/examples/enum.js +++ b/examples/enum.js @@ -4,7 +4,7 @@ import { unit } from "../lib/primitives/unit.js"; import { makeConstructors, makeMatchFn } from "../lib/structures/enum.js"; import { enumType } from "../lib/structures/enum.types.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"; Error.stackTraceLimit = Infinity; @@ -15,10 +15,10 @@ const variants = [ newProduct("not_found")(_ => Unit), ]; -const compatibleNestedSumType = enumType(variants); +const structuralType = enumType(variants); console.log("observe the type that was generated:"); -console.log(" ", prettyT(compatibleNestedSumType)); +console.log(" ", prettyT(structuralType)); const [newPrice, newPrices, newNotFound] = makeConstructors(variants); @@ -41,7 +41,7 @@ console.log(" ", myEnumToString(price)); console.log(" ", myEnumToString(prices)); console.log(" ", myEnumToString(notFound)); -const compareMyEnum = makeCompareFn(compatibleNestedSumType); +const compareMyEnum = makeCompareFn(structuralType); console.log("observe the generated compare function in action:"); console.log(" should be smaller ->", compareMyEnum(price)(prices)); diff --git a/lib/structures/enum.types.js b/lib/structures/enum.types.js index bb17875..3c3fd6c 100644 --- a/lib/structures/enum.types.js +++ b/lib/structures/enum.types.js @@ -1,10 +1,10 @@ import { makeCompareFn } from "../compare/dynamic.js"; import { makeGeneric } from "../generics/generics.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 { 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. // e.g., the list of variants: @@ -77,4 +77,5 @@ export const makeModuleEnum = type => variants => { // compare-function: newDynamic(makeCompareFn(enumType(variants))) ]; + return module; } \ No newline at end of file