basic functionality, no generics

This commit is contained in:
Joeri Exelmans 2025-03-14 16:56:37 +01:00
commit a8260f2afb
17 changed files with 615 additions and 0 deletions

14
primitives/bool.js Normal file
View file

@ -0,0 +1,14 @@
import {Type, Function} from "../metacircular.js";
import {Bool} from "./symbols.js";
const eqBool = x => y => x === y;
const Bool_to_Bool = {in: Bool, out: Bool};
const Bool_to_Bool_to_Bool = {in: Bool, out: Bool_to_Bool};
export const ModuleBool = [
{i: Bool , t: Type },
{i: Bool_to_Bool , t: Function },
{i: Bool_to_Bool_to_Bool , t: Function },
{i: eqBool , t: Bool_to_Bool_to_Bool },
];

26
primitives/double.js Normal file
View file

@ -0,0 +1,26 @@
import {Type, Function} from "../metacircular.js";
import {Bool, Double} from "./symbols.js";
export const addDouble = x => y => x + y;
export const mulDouble = x => y => x * y;
export const eqDouble = x => y => x === y;
const Double_to_Double = {in: Double, out: Double};
const Double_to_Bool = {in: Double, out: Bool};
export const Double_to_Double_to_Double = {in: Double, out: Double_to_Double};
export const Double_to_Double_to_Bool = {in: Double, out: Double_to_Bool};
export const ModuleDouble = [
{i: Double , t: Type },
{i: Double_to_Double_to_Double, t: Function },
{i: Double_to_Double_to_Bool , t: Function },
{i: Double_to_Double , t: Function },
{i: Double_to_Bool , t: Function },
{i: addDouble , t: Double_to_Double_to_Double },
{i: mulDouble , t: Double_to_Double_to_Double },
{i: eqDouble , t: Double_to_Double_to_Bool },
];

26
primitives/int.js Normal file
View file

@ -0,0 +1,26 @@
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 = {in: Int, out: Int };
const Int_to_Bool = {in: Int, out: Bool};
export const Int_to_Int_to_Int = {in: Int, out: Int_to_Int};
export const Int_to_Int_to_Bool = {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 },
];

5
primitives/symbols.js Normal file
View file

@ -0,0 +1,5 @@
// to break up dependency cycles, symbols of primitive types have their own JS module
export const Bool = Symbol('Bool');
export const Int = Symbol('Int');
export const Double = Symbol('Double');