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

@ -15,8 +15,8 @@ export const constructorRight = right => ({t: "R", v: right});
// sum-type -> (leftType -> resultType, rightType -> resultType) -> resultType
export const match = sum => handlers =>
sum.t === "L"
? handlers.left(sum.v)
: handlers.right(sum.v);
? handlers.l(sum.v)
: handlers.r(sum.v);
export const ModuleSum = {l:[
// binary type constructor