progress and some refactoring
This commit is contained in:
parent
d236eca5e5
commit
d8ca2f3999
25 changed files with 376 additions and 163 deletions
22
type.js
22
type.js
|
|
@ -1,12 +1,10 @@
|
|||
import { Bool, Type } from "./primitives/types.js";
|
||||
import { typedFnType } from "./structures/types.js";
|
||||
import { deepEqual } from "./util.js";
|
||||
|
||||
export const getSymbol = type => type.symbol;
|
||||
export const getParams = type => type.params;
|
||||
import { Bool, SymbolT, Type } from "./primitives/types.js";
|
||||
import { isFunction, lsType, typedFnType } from "./structures/types.js";
|
||||
import { getSymbol, getParams } from "./type_constructor.js";
|
||||
import { deepEqual } from "./util/util.js";
|
||||
|
||||
// we can test whether types are equal:
|
||||
export const eqType = deepEqual;
|
||||
export const eqType = t1 => t2 => deepEqual(t1, t2);
|
||||
|
||||
// a module is just a set of typed objects
|
||||
// each 'typed object' is implicitly an instance of TypeLink (defined below)
|
||||
|
|
@ -17,13 +15,8 @@ export const ModuleType = {l:[
|
|||
// ...
|
||||
// see: https://lean-lang.org/functional_programming_in_lean/functor-applicative-monad/universes.html
|
||||
|
||||
// Type :: Type
|
||||
{i: Type, t: Type},
|
||||
|
||||
// ...typedFnType(getSymbol, fnType => fnType({in: Type, out: Int})),
|
||||
|
||||
// ...typedFnType(getParams, fnType => fnType({in: Type, out: lsType(Type)})),
|
||||
|
||||
// Type -> Type -> Bool
|
||||
...typedFnType(eqType, fnType =>
|
||||
fnType
|
||||
|
|
@ -32,4 +25,9 @@ export const ModuleType = {l:[
|
|||
(Type)
|
||||
(Bool)
|
||||
)),
|
||||
|
||||
...typedFnType(getSymbol, fnType => fnType(Type)(SymbolT)),
|
||||
...typedFnType(getParams, fnType => fnType(Type)(lsType(Type))),
|
||||
|
||||
...typedFnType(isFunction, fnType => fnType(Type)(Bool)),
|
||||
]};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue