simplify: no distinction between generic types and 'normal' types.

This commit is contained in:
Joeri Exelmans 2025-05-08 16:58:07 +02:00
parent b4826605af
commit a664ddac8a
27 changed files with 535 additions and 360 deletions

View file

@ -1,4 +1,3 @@
import { fnType } from "../structures/types.js";
import { deepEqual } from "../util/util.js";
import { inspect } from "node:util";
@ -20,7 +19,7 @@ export const read = slot => ({
// Value<a> -> Value<a -> b> -> Value<b>
export const transform = input => fn => {
const output = fn.out(input.out);
const _inspect = (depth, options, inspect) => `transform(${inspect(input)}, ${inspect(fn)})`;
// const _inspect = (depth, options, inspect) => `transform(${inspect(input)}, ${inspect(fn)})`;
if (input.kind === "literal") {
// optimization: sandwich everything together
return {
@ -31,7 +30,7 @@ export const transform = input => fn => {
}
else {
return {
kind: "transformation",
kind: "transform",
in: input,
fn,
out: output,
@ -48,7 +47,7 @@ export const getReadDependencies = value => {
else if (value.kind === "read") {
return new Set([value.slot]);
}
else if (value.kind === "transformation") {
else if (value.kind === "transform") {
return new Set([
...getReadDependencies(value.in),
...getReadDependencies(value.fn),
@ -80,9 +79,9 @@ export const verifyValue = (value, indent = 0) => {
else if (value.kind === "read") {
compare(value.out, value.slot.value.out, "read");
}
else if (value.kind === "transformation") {
else if (value.kind === "transform") {
compare(value.fn.out(value.in.out),
value.out, "transformation");
value.out, "transform");
success &= verifyValue(value.in, indent + 1);
success &= verifyValue(value.fn, indent + 1);