This commit is contained in:
Joeri Exelmans 2025-03-24 17:28:07 +01:00
parent 6af72e525c
commit 145835ad5d
22 changed files with 153 additions and 90 deletions

View file

@ -1,4 +1,4 @@
import { Type } from "../type.js";
import { Type } from "../primitives/types.js";
import { typedFnType } from "./types.js";
import { fnType } from "./types.js";

View file

@ -1,5 +1,5 @@
import { fnType, typedFnType } from "./types.js";
import { Type } from "../type.js";
import { Type } from "../primitives/types.js";
import { Int } from "../primitives/types.js";
import { makeGeneric } from "../generics/generics.js";
import { lsType } from "./types.js";

View file

@ -1,5 +1,5 @@
import { makeGeneric } from "../generics/generics.js";
import { Type } from "../type.js";
import { Type } from "../primitives/types.js";
import { typedFnType } from "./types.js";
import { prodType } from "./types.js";

View file

@ -1,15 +1,15 @@
import { prodType } from "./types.js";
import { Type } from "../type.js";
import { Type } from "../primitives/types.js";
import { typedFnType } from "./types.js";
import { makeGeneric } from "../generics/generics.js";
import { sumType } from "./types.js";
const constructorLeft = left => ({variant: "L", value: left });
const constructorRight = right => ({variant: "R", value: right});
export const constructorLeft = left => ({variant: "L", value: left });
export const constructorRight = right => ({variant: "R", value: right});
// signature:
// sum-type -> (leftType -> resultType, rightType -> resultType) -> resultType
const match = sum => handlers => sum.variant === "L"
export const match = sum => handlers => sum.variant === "L"
? handlers.left(sum.value)
: handlers.right(sum.value);

View file

@ -1,6 +1,6 @@
// to break up dependency cycles, type constructors are defined in their own JS module
import { Type } from "../type.js";
import { Type } from "../primitives/types.js";
import { DefaultMap } from "../util.js";