add enum type (generalization of sum-type)

This commit is contained in:
Joeri Exelmans 2025-04-17 16:10:00 +02:00
parent 8653bb99c6
commit 0b262daf7f
6 changed files with 102 additions and 7 deletions

View file

@ -1,12 +1,9 @@
import { Unit } from "../primitives/types.js";
import { unit } from "../primitives/unit.js";
import { capitalizeFirstLetter } from "../util/util.js";
import { constructorProduct, getLeft, getRight } from "./product.js";
import { fnType, prodType } from "./types.js";
function capitalizeFirstLetter(val) {
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
}
// 'fields' is an array of (name: string, type: Type) pairs.
// e.g.:
// [{l: "x", r: Double}, {l: "y", r: Double}]