import { fnType, prodType } from "../type_registry.js"; import { Function } from "../metacircular.js"; // In JS, all products are encoded in the same way: const constructor = left => right => ({left, right}); const left = product => product.left; const right = product => product.right; // Given two types A and B, create the type (A × B). export const makeProductType = (leftType, rightType) => { const productType = prodType(leftType, rightType); const leftFnType = fnType({in: productType, out: leftType}); const rightFnType = fnType({in: productType, out: rightType}); const constructorBoundType = fnType({in: rightType, out: productType}); const constructorType = fnType({in: leftType, out: constructorBoundType}); return [ {i: left , t: leftFnType}, {i: right , t: rightFnType}, {i: leftFnType , t: Function}, {i: rightFnType, t: Function}, {i: constructor , t: constructorType}, {i: constructorType , t: Function}, {i: constructorBoundType, t: Function}, ]; };