Add product and sum types

This commit is contained in:
Joeri Exelmans 2025-03-17 17:54:42 +01:00
parent 6023efc295
commit 574651ccb7
18 changed files with 209 additions and 157 deletions

View file

@ -0,0 +1,27 @@
import { fnType } from "../type_registry.js";
import {Type, Function} from "../metacircular.js";
import {Bool, Int} from "./symbols.js";
export const addInt = x => y => x + y;
export const mulInt = x => y => x * y;
export const eqInt = x => y => x === y;
const Int_to_Int = fnType({in: Int, out: Int });
const Int_to_Bool = fnType({in: Int, out: Bool});
export const Int_to_Int_to_Int = fnType({in: Int, out: Int_to_Int});
export const Int_to_Int_to_Bool = fnType({in: Int, out: Int_to_Bool});
export const ModuleInt = [
{i: Int , t: Type },
{i: Int_to_Int_to_Int , t: Function },
{i: Int_to_Int_to_Bool , t: Function },
{i: Int_to_Int , t: Function },
{i: Int_to_Bool , t: Function },
{i: addInt , t: Int_to_Int_to_Int },
{i: mulInt , t: Int_to_Int_to_Int },
{i: eqInt , t: Int_to_Int_to_Bool },
];