39 lines
945 B
JavaScript
39 lines
945 B
JavaScript
import { makeGeneric } from "../generics/generics";
|
|
import { Type } from "../type";
|
|
import { typedFnType } from "../structures/types";
|
|
import { Bool, Byte, Char, Double, Int } from "../primitives/types";
|
|
import { deepEqual } from "../util";
|
|
import { eqDictType } from "./eq_type";
|
|
|
|
export const getEq = numDict => numDict.eq;
|
|
|
|
export const ModuleEq = {l:[
|
|
...typedFnType(eqDictType, fnType => fnType({in: Type, out: Type})),
|
|
|
|
...typedFnType(getEq, fnType => makeGeneric(a =>
|
|
fnType({
|
|
in: eqDictType(a),
|
|
out: fnType({
|
|
in: a,
|
|
out: fnType({
|
|
in: a,
|
|
out: Bool,
|
|
}),
|
|
}),
|
|
}))),
|
|
]};
|
|
|
|
// all our data (and types) are encoded such that we can test equality the same way:
|
|
|
|
const eq = x => y => deepEqual(x,y);
|
|
|
|
const EqDict = {eq};
|
|
|
|
export const EqInstances = new Map([
|
|
[Int, EqDict],
|
|
[Bool, EqDict],
|
|
[Double, EqDict],
|
|
[Byte, EqDict],
|
|
[Char, EqDict],
|
|
[Type, EqDict],
|
|
]);
|