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

11
lib/structures/sum.js Normal file
View file

@ -0,0 +1,11 @@
// Sum-type (also called: tagged union, disjoint union, variant type)
// A Sum-type always has only two variants, called "left" and "right".
// Sum-types of more variants (called Enums) can be constructed by nesting Sum-types.
export const newLeft = left => ({t: "L", v: left });
export const newRight = right => ({t: "R", v: right});
export const match = sum => leftHandler => rightHandler =>
sum.t === "L"
? leftHandler(sum.v)
: rightHandler(sum.v);