reorganize directory and file structure

This commit is contained in:
Joeri Exelmans 2025-05-07 13:44:49 +02:00
parent 1d826ea8d4
commit 48390b8556
99 changed files with 1155 additions and 1629 deletions

View file

@ -1,13 +1,15 @@
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 { newProduct } from "../structures/product.js";
import { lsType, prettyT } from "../structures/types.js";
import { makeCompareFn } from "../lib/compare/registry.js";
import { Int, Unit } from "../lib/primitives/primitive_types.js";
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 { prettyT } from "../lib/util/pretty.js";
const variants = [
newProduct("price")(Int),
newProduct("prices")(lsType(() =>Int)),
newProduct("prices")(lsType(_ => Int)),
newProduct("not_found")(Unit),
];
@ -19,7 +21,7 @@ console.log(" ", prettyT(myEnumType));
const [newPrice, newPrices, newNotFound] = makeConstructors(variants);
const price = newPrice(10);
const prices = newPrices({ l: [20, 30] });
const prices = newPrices([20, 30]);
const notFound = newNotFound(unit);
console.log("observe the encoding of different variant instances:");
@ -29,7 +31,7 @@ console.log(" ", notFound);
const myEnumToString = x => makeMatchFn(variants)(x)
(price => `Price: ${price}`)
(prices => `Prices: ${prices.l}`)
(prices => `Prices: ${prices}`)
(() => "Not found!");
console.log("observe the generated match function in action:");
@ -40,9 +42,9 @@ console.log(" ", myEnumToString(notFound));
const compareMyEnum = makeCompareFn(myEnumType);
console.log("observe the generated compare function in action:");
console.log(" smaller ->", compareMyEnum(price)(prices));
console.log(" bigger ->", compareMyEnum(prices)(price));
console.log(" bigger ->", compareMyEnum(notFound)(price));
console.log(" equal ->", compareMyEnum(prices)(prices));
console.log(" smaller ->", compareMyEnum(newPrice(5))(newPrice(6)));
console.log(" bigger ->", compareMyEnum(newPrices({ l: [5, 6] }))(newPrices({ l: [5, 5] })));
console.log(" should be smaller ->", compareMyEnum(price)(prices));
console.log(" should be bigger ->", compareMyEnum(prices)(price));
console.log(" should be bigger ->", compareMyEnum(notFound)(price));
console.log(" should be equal ->", compareMyEnum(prices)(prices));
console.log(" should be smaller ->", compareMyEnum(newPrice(5))(newPrice(6)));
console.log(" should be bigger ->", compareMyEnum(newPrices([5, 6]))(newPrices([5, 5])));