refactor code: move everything from type_registry to "most appropriate" modules
This commit is contained in:
parent
4ca60784aa
commit
5283be608b
22 changed files with 160 additions and 164 deletions
|
|
@ -1,20 +1,21 @@
|
|||
import { Bool, Int } from "../primitives/symbols.js";
|
||||
import { fnType, lsType } from "../type_registry.js";
|
||||
import { assign, makeGeneric, matchConcrete, matchGeneric } from "./generics.js";
|
||||
import { lsType } from "../structures/list_common.js";
|
||||
import { fnType } from "../metacircular.js";
|
||||
import { assign, makeGeneric, unify } from "./generics.js";
|
||||
|
||||
// a -> Int
|
||||
const a_to_Int = makeGeneric(a => fnType({in: a, out: Int}));
|
||||
// Bool -> Int
|
||||
const Bool_to_Int = fnType({in: lsType(Bool), out: Int});
|
||||
const Bool_to_Int = makeGeneric(() => fnType({in: lsType(Bool), out: Int}));
|
||||
// should be: Bool -> Int
|
||||
console.log(matchConcrete(a_to_Int, Bool_to_Int));
|
||||
console.log(unify(a_to_Int, Bool_to_Int));
|
||||
|
||||
// (a -> a) -> b
|
||||
const fnType2 = makeGeneric((a,b) => fnType({in: fnType({in: a, out: a}), out: b}));
|
||||
// (Bool -> Bool) -> a
|
||||
const fnType3 = makeGeneric(a => fnType({in: fnType({in: Bool, out: Bool}), out: a}));
|
||||
// should be: (Bool -> Bool) -> a
|
||||
console.log(matchGeneric(fnType2, fnType3));
|
||||
console.log(unify(fnType2, fnType3));
|
||||
|
||||
// (a -> b) -> [a] -> [b]
|
||||
const mapFnType = makeGeneric((a,b) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue