lotta progress
This commit is contained in:
parent
29d20b2273
commit
bc91d9bf39
27 changed files with 317 additions and 475 deletions
|
|
@ -1,18 +1,8 @@
|
|||
import { typedFnType } from "./function.js";
|
||||
import { Type } from "../metacircular.js";
|
||||
import { Int } from "../primitives/symbols.js";
|
||||
import { DefaultMap } from "../util.js";
|
||||
import { typedFnType } from "./types.js";
|
||||
import { Type } from "../type.js";
|
||||
import { Int } from "../primitives/types.js";
|
||||
import { makeGeneric } from "../generics/generics.js";
|
||||
|
||||
const symbolList = Symbol('List');
|
||||
|
||||
const listTypeRegistry = new DefaultMap(elementType => ({
|
||||
symbol: symbolList,
|
||||
params: [elementType],
|
||||
}));
|
||||
|
||||
// type constructor
|
||||
export const lsType = elementType => listTypeRegistry.getdefault(elementType, true);
|
||||
import { lsType } from "./types.js";
|
||||
|
||||
// 'normal' implementation
|
||||
const emptyList = {l:[]};
|
||||
|
|
@ -22,30 +12,35 @@ const put = ls => i => elem => ({l: ls.l.with(Number(i), elem)});
|
|||
|
||||
export const ModuleList = {l:[
|
||||
// Type -> Type
|
||||
...typedFnType(lsType, fnType => fnType
|
||||
/* in */ (Type)
|
||||
/* out */ (Type)
|
||||
...typedFnType(lsType, fnType =>
|
||||
fnType
|
||||
/* in */ (Type)
|
||||
/* out */ (Type)
|
||||
),
|
||||
|
||||
// [a]
|
||||
{i: emptyList, t: makeGeneric(a => lsType(a))},
|
||||
|
||||
// [a] -> Int -> a
|
||||
...typedFnType(get, fnType => makeGeneric(a => fnType
|
||||
/* in */ (lsType(a))
|
||||
/* out */ (fnType
|
||||
/* in */ (Int)
|
||||
/* out */ (a)
|
||||
))),
|
||||
...typedFnType(get, fnType =>
|
||||
makeGeneric(a =>
|
||||
fnType
|
||||
/* in */ (lsType(a))
|
||||
/* out */ (fnType
|
||||
/* in */ (Int)
|
||||
/* out */ (a)
|
||||
))),
|
||||
|
||||
// [a] -> Int -> a -> [a]
|
||||
...typedFnType(put, fnType => makeGeneric(a => fnType
|
||||
/* in */ (lsType(a))
|
||||
/* out */ (fnType
|
||||
/* in */ (Int)
|
||||
/* out */ (fnType
|
||||
/* in */ (a)
|
||||
/* out */ (lsType(a))
|
||||
)
|
||||
))),
|
||||
...typedFnType(put, fnType =>
|
||||
makeGeneric(a =>
|
||||
fnType
|
||||
/* in */ (lsType(a))
|
||||
/* out */ (fnType
|
||||
/* in */ (Int)
|
||||
/* out */ (fnType
|
||||
/* in */ (a)
|
||||
/* out */ (lsType(a))
|
||||
)
|
||||
))),
|
||||
]};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue