recursive types (and operations on them, like pretty-printing, comparison and unification) seem to be working.
big part of the code base still needs to be 'ported' to the updated type constructors.
This commit is contained in:
parent
55c5d7cffa
commit
8eec5b9239
34 changed files with 523 additions and 295 deletions
|
|
@ -7,7 +7,7 @@ import { Dynamic } from "../primitives/dynamic.js"
|
|||
|
||||
// 'normal' implementation
|
||||
export const emptyList = {l:[]};
|
||||
const emptyListType = makeGeneric(a => lsType(a));
|
||||
// const emptyListType = makeGeneric(a => lsType(() => a));
|
||||
export const get = ls => i => ls.l[i];
|
||||
export const put = ls => i => elem => ({l: ls.l.with(Number(i), elem)});
|
||||
export const push = ls => elem => ({l:ls.l.concat([elem])});
|
||||
|
|
@ -21,62 +21,62 @@ export const fold = ls => callback => initial => {
|
|||
return acc;
|
||||
}
|
||||
|
||||
export const String = lsType(Char); // alias
|
||||
export const Module = lsType(Dynamic);
|
||||
export const String = lsType(() =>Char); // alias
|
||||
export const Module = lsType(() =>Dynamic);
|
||||
|
||||
export const ModuleList = {l:[
|
||||
// Type -> Type
|
||||
...typedFnType(lsType, fnType =>
|
||||
fnType
|
||||
/* in */ (Type)
|
||||
/* out */ (Type)
|
||||
),
|
||||
// // Type -> Type
|
||||
// ...typedFnType(lsType, fnType =>
|
||||
// fnType
|
||||
// /* in */ (Type)
|
||||
// /* out */ (Type)
|
||||
// ),
|
||||
|
||||
// [a]
|
||||
{i: emptyList, t: emptyListType},
|
||||
{i: emptyListType, t: GenericType},
|
||||
// // [a]
|
||||
// // {i: emptyList, t: emptyListType},
|
||||
// // {i: emptyListType, t: GenericType},
|
||||
|
||||
// [a] -> Int -> a
|
||||
...typedFnType(get, fnType =>
|
||||
makeGeneric(a =>
|
||||
fnType
|
||||
/* in */ (lsType(a))
|
||||
/* out */ (fnType
|
||||
/* in */ (Int)
|
||||
/* out */ (a)
|
||||
)), GenericType),
|
||||
// // [a] -> Int -> a
|
||||
// ...typedFnType(get, fnType =>
|
||||
// makeGeneric(a =>
|
||||
// fnType
|
||||
// /* in */ (() => lsType(() => a))
|
||||
// /* out */ (() => fnType
|
||||
// /* in */ (() => Int)
|
||||
// /* out */ (() => a)
|
||||
// )), GenericType),
|
||||
|
||||
// [a] -> Int -> a -> [a]
|
||||
...typedFnType(put, fnType =>
|
||||
makeGeneric(a =>
|
||||
fnType
|
||||
/* in */ (lsType(a))
|
||||
/* out */ (fnType
|
||||
/* in */ (Int)
|
||||
/* out */ (fnType
|
||||
/* in */ (a)
|
||||
/* out */ (lsType(a))
|
||||
)
|
||||
)), GenericType),
|
||||
// // [a] -> Int -> a -> [a]
|
||||
// ...typedFnType(put, fnType =>
|
||||
// makeGeneric(a =>
|
||||
// fnType
|
||||
// /* in */ (() => lsType(() => a))
|
||||
// /* out */ (() => fnType
|
||||
// /* in */ (() => Int)
|
||||
// /* out */ (() => fnType
|
||||
// /* in */ (() => a)
|
||||
// /* out */ (() => lsType(() => a))
|
||||
// )
|
||||
// )), GenericType),
|
||||
|
||||
// [a] -> a -> [a]
|
||||
...typedFnType(push, fnType =>
|
||||
makeGeneric(a =>
|
||||
fnType
|
||||
(lsType(a))
|
||||
(fnType
|
||||
(a)
|
||||
(lsType(a))
|
||||
)
|
||||
), GenericType),
|
||||
// // [a] -> a -> [a]
|
||||
// ...typedFnType(push, fnType =>
|
||||
// makeGeneric(a =>
|
||||
// fnType
|
||||
// (() => lsType(() => a))
|
||||
// (() => fnType
|
||||
// (() => a)
|
||||
// (() => lsType(() => a))
|
||||
// )
|
||||
// ), GenericType),
|
||||
|
||||
// [a] -> (a -> b) -> [b]
|
||||
...typedFnType(map, fnType =>
|
||||
makeGeneric((a, b) =>
|
||||
fnType
|
||||
(lsType(a))
|
||||
(fnType
|
||||
(fnType(a)(b))
|
||||
(lsType(b))
|
||||
)), GenericType),
|
||||
// // [a] -> (a -> b) -> [b]
|
||||
// ...typedFnType(map, fnType =>
|
||||
// makeGeneric((a, b) =>
|
||||
// fnType
|
||||
// (() => lsType(() => a))
|
||||
// (() => fnType
|
||||
// (() => fnType(() => a)(() => b))
|
||||
// (() => lsType(() => b))
|
||||
// )), GenericType),
|
||||
]};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue