branching and very basic merging of slots

This commit is contained in:
Joeri Exelmans 2025-04-17 09:19:41 +02:00
parent 614e6c0fdb
commit 3978f7f835
32 changed files with 684 additions and 420 deletions

View file

@ -1,4 +1,4 @@
import { typedFnType } from "./types.js";
import { fnType, typedFnType } from "./types.js";
import { Char, GenericType, Type } from "../primitives/types.js";
import { Int } from "../primitives/types.js";
import { makeGeneric } from "../generics/generics.js";
@ -11,6 +11,7 @@ const emptyListType = makeGeneric(a => lsType(a));
const get = ls => i => ls.l[i];
const put = ls => i => elem => ({l: ls.l.with(Number(i), elem)});
const push = ls => elem => ({l:ls.l.concat([elem])});
const map = ls => fn => ({ l: ls.l.map(elem => fn(elem)) });
export const String = lsType(Char); // alias
export const Module = lsType(Typed);
@ -60,4 +61,14 @@ export const ModuleList = {l:[
(lsType(a))
)
), GenericType),
// [a] -> (a -> b) -> [b]
...typedFnType(map, fnType =>
makeGeneric((a, b) =>
fnType
(lsType(a))
(fnType
(fnType(a)(b))
(lsType(b))
)), GenericType),
]};