import { makeGeneric } from "../generics/generics"; import { Type } from "../metacircular"; import { typedFnType } from "../structures/function"; import { Bool, Byte, Char, Double, Int } from "../primitives/symbols"; 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], ]);