progress with type classes, type inference still very ad-hoc
This commit is contained in:
parent
5283be608b
commit
c5ac55b0ff
10 changed files with 64 additions and 19 deletions
|
|
@ -1,10 +1,9 @@
|
|||
import { makeGeneric } from "../generics/generics";
|
||||
import { addDouble, mulDouble } from "../primitives/double";
|
||||
import { addInt, mulInt } from "../primitives/int";
|
||||
import { typedFnType, typedFnType2 } from "../metacircular";
|
||||
|
||||
const numDictTypeRegistry = new DefaultMap(a => ({numDict: a}));
|
||||
export const numDictType = a => numDictTypeRegistry.getdefault(a, true);
|
||||
import { makeGeneric } from "../generics/generics.js";
|
||||
import { addDouble, mulDouble } from "../primitives/double.js";
|
||||
import { addInt, mulInt } from "../primitives/int.js";
|
||||
import { Type, typedFnType, typedFnType2 } from "../metacircular.js";
|
||||
import { Double, Int } from "../primitives/symbols.js";
|
||||
import { numDictType } from "./num_type.js";
|
||||
|
||||
export const getAdd = numDict => numDict.add;
|
||||
export const getMul = numDict => numDict.mul;
|
||||
|
|
@ -40,8 +39,8 @@ const DoubleNumDict = {
|
|||
}
|
||||
|
||||
export const ModuleNumInstances = {l:[
|
||||
{i: IntNumDict , t: NumDict},
|
||||
{i: DoubleNumDict, t: NumDict},
|
||||
{i: IntNumDict , t: numDictType(Int)},
|
||||
{i: DoubleNumDict, t: numDictType(Double)},
|
||||
]};
|
||||
|
||||
// mapping from type to type class implementation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue