lotta progress

This commit is contained in:
Joeri Exelmans 2025-03-23 13:25:47 +01:00
parent 29d20b2273
commit bc91d9bf39
27 changed files with 317 additions and 475 deletions

View file

@ -1,15 +1,15 @@
import { fnType } from "../structures/function.js";
import { Type } from "../metacircular.js";
import { Bool } from "./symbols.js";
import { fnType, typedFnType } from "../structures/types.js";
import { Type } from "../type.js";
import { Bool } from "./types.js";
const eqBool = x => y => x === y;
const Bool_to_Bool = fnType({in: Bool, out: Bool});
const Bool_to_Bool_to_Bool = fnType({in: Bool, out: Bool_to_Bool});
export const ModuleBool = {l:[
{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 },
{i: true , t: Bool},
{i: false, t: Bool},
{i: Bool , t: Type},
// Bool -> Bool -> Bool
...typedFnType(eqBool, fnType => fnType(Bool)(fnType(Bool)(Bool))),
]};

View file

@ -1,15 +1,11 @@
import { fnType } from "../structures/function.js";
import { Type } from "../metacircular.js";
import {Byte, Bool} from "./symbols.js";
import { typedFnType } from "../structures/types.js";
import { Type } from "../type.js";
import {Byte, Bool} from "./types.js";
const eqByte = x => y => x === y;
const Byte_to_Bool = fnType({in: Byte, out: Bool});
const Byte_to_Byte_to_Bool = fnType({in: Byte, out: Byte_to_Bool});
export const ModuleByte = {l:[
{i: Byte , t: Type },
{i: Byte_to_Bool , t: Function },
{i: Byte_to_Byte_to_Bool , t: Function },
{i: eqByte , t: Byte_to_Byte_to_Bool },
...typedFnType(eqByte, fnType => fnType(Byte)(fnType(Byte)(Bool))),
]};

View file

@ -1,6 +1,6 @@
import { typedFnType } from "../structures/function.js";
import { Type } from "../metacircular.js";
import {Char, Bool} from "./symbols.js";
import { typedFnType } from "../structures/types.js";
import { Type } from "../type.js";
import {Char, Bool} from "./types.js";
const eq = x => y => x === y;

View file

@ -1,26 +1,15 @@
import { fnType } from "../structures/function.js";
import { Type } from "../metacircular.js";
import {Bool, Double} from "./symbols.js";
import { typedFnType } from "../structures/types.js";
import { Type } from "../type.js";
import {Bool, Double} from "./types.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 = fnType({in: Double, out: Double});
const Double_to_Bool = fnType({in: Double, out: Bool});
export const Double_to_Double_to_Double = fnType({in: Double, out: Double_to_Double});
export const Double_to_Double_to_Bool = fnType({in: Double, out: Double_to_Bool});
export const ModuleDouble = {l:[
{i: Double , t: Type },
{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 },
...typedFnType(addDouble, fnType => fnType(Double)(fnType(Double)(Double))),
...typedFnType(mulDouble, fnType => fnType(Double)(fnType(Double)(Double))),
...typedFnType(eqDouble, fnType => fnType(Double)(fnType(Double)(Bool))),
]};

View file

@ -1,30 +1,19 @@
import { fnType } from "../structures/function.js";
import { Type } from "../metacircular.js";
import { typedFnType } from "../structures/types.js";
import { Type } from "../type.js";
import {Bool, Int} from "./symbols.js";
import {Bool, Int} from "./types.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});
const serialize = x => x.toString();
const deserialize = str => BigInt(str);
export const ModuleInt = {l:[
{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 },
...typedFnType(addInt, fnType => fnType(Int)(fnType(Int)(Int))),
...typedFnType(mulInt, fnType => fnType(Int)(fnType(Int)(Int))),
...typedFnType(eqInt , fnType => fnType(Int)(fnType(Int)(Bool))),
]};

View file

@ -1,7 +1,8 @@
// to break up dependency cycles, primitive types are defined in their own JS module
export const Int = { symbol: Symbol('Int') , params: [] };
export const Bool = { symbol: Symbol('Bool') , params: [] };
export const Double = { symbol: Symbol('Double'), params: [] };
export const Byte = { symbol: Symbol('Byte') , params: [] };
export const Char = { symbol: Symbol('Char') , params: [] };
export const Char = { symbol: Symbol('Char') , params: [] };// Wrapper around function below.