import { Dynamic } from "../primitives/dynamic.js"; import { Int } from "../primitives/types.js"; import { enumType } from "../structures/enum.js"; import { newProduct } from "../structures/product.js"; import { structType } from "../structures/struct.js"; import { prettyT, prodType } from "../structures/types.js"; const Slot = structType([ newProduct("value")(() => Value), newProduct("depth")(() => Int), newProduct("overwrites")(() => Slot), ]); // A Value is either: // - a literal, without any dependencies. // - read from a slot. the Value then has a read-dependency on that slot. // - a transformation of another Value, by a function. the function is also a Value. const variants = [ newProduct("literal", () => Dynamic), newProduct("read", () => Slot), newProduct("transformation", () => prodType(Value, Dynamic)), ]; const Value = enumType(variants); // console.log(prettyT(Slot)); // console.log(prettyT(Value));