use fnType everywhere to create function types

This commit is contained in:
Joeri Exelmans 2025-03-14 17:05:04 +01:00
parent a8260f2afb
commit 6023efc295
10 changed files with 33 additions and 27 deletions

View file

@ -1,3 +1,4 @@
import { fnType } from "../function_registry.js";
import {Function} from "../metacircular.js";
// import {Typed} from "../typed.js";
@ -29,7 +30,7 @@ import {Function} from "../metacircular.js";
// generates explicitly typed id-function
export const makeIdFn = typ => {
const Typ_to_Typ = {in: typ, out: typ};
const Typ_to_Typ = fnType({in: typ, out: typ});
const id = x => x;
return [
{i: id , t: Typ_to_Typ},

View file

@ -2,6 +2,7 @@ import {Function, getIn, getOut} from "../metacircular.js";
import {Module} from "../structures/module.js";
import { deepEqual } from "../util.js";
import { Typed } from "../typed.js";
import { fnType } from "../function_registry.js";
// import {Num, NumDict, getType, getMul} from "../typeclasses/num.js";
@ -34,14 +35,14 @@ export const makeSquare = ({i: mul, t: mulFunction}) => {
throw new Error("invalid signature");
}
const square = x => mul(x)(x);
const squareFunction = {in: numType, out: numType};
const squareFunction = fnType({in: numType, out: numType});
return [
{i: square , t: squareFunction},
{i: squareFunction, t: Function},
];
};
const makeSquareType = {in: Typed, out: Module};
const makeSquareType = fnType({in: Typed, out: Module});
export const ModuleSquare = [
{i: makeSquare , t: makeSquareType},