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,8 +1,9 @@
import { fnType } from "../function_registry.js";
import {Type, Function} from "../metacircular.js";
import { makeListModule } from "./list_common.js";
const Type_to_Type = {in: Type, out: Type};
const Type_to_Module = {in: Type, out: Module};
const Type_to_Type = fnType({in: Type, out: Type});
const Type_to_Module = fnType({in: Type, out: Module});
export const ModuleList = [
{i: getListType , t: Type_to_Type},

View file

@ -1,3 +1,4 @@
import { fnType } from "../function_registry.js";
import {Type, Function} from "../metacircular.js";
import {Int} from "../primitives/symbols.js";
@ -24,12 +25,12 @@ export const makeListModule = elementType => {
const emptyList = {l:[]};
const get = ls => i => ls.l[i];
const getBoundType = {in: Int, out: elementType}
const getType = {in: ListOfElement, out: getBoundType};
const getBoundType = fnType({in: Int, out: elementType});
const getType = fnType({in: ListOfElement, out: getBoundType});
const push = ls => elem => ({l:ls.l.concat([elem])});
const pushBoundType = {in: elementType, out: ListOfElement};
const pushType = {in: ListOfElement, out: pushBoundType};
const pushBoundType = fnType({in: elementType, out: ListOfElement});
const pushType = fnType({in: ListOfElement, out: pushBoundType});
return [
{i: ListOfElement, t: Type},