list of byte encoded as JS Uint8Array + demo more readable

This commit is contained in:
Joeri Exelmans 2025-03-17 20:14:57 +01:00
parent 574651ccb7
commit 3d08485a08
6 changed files with 102 additions and 37 deletions

View file

@ -3,8 +3,8 @@ 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;
const getLeft = product => product.left;
const getRight = product => product.right;
// Given two types A and B, create the type (A × B).
export const makeProductType = (leftType, rightType) => {
@ -14,11 +14,11 @@ export const makeProductType = (leftType, rightType) => {
const rightFnType = fnType({in: productType, out: rightType});
const constructorBoundType = fnType({in: rightType, out: productType});
const constructorType = fnType({in: leftType, out: constructorBoundType});
const constructorType = fnType({in: leftType , out: constructorBoundType});
return [
{i: left , t: leftFnType},
{i: right , t: rightFnType},
{i: getLeft , t: leftFnType},
{i: getRight , t: rightFnType},
{i: leftFnType , t: Function},
{i: rightFnType, t: Function},