import { makeGeneric } from "../generics/generics"; import { GenericType, SymbolT, Type, Unit } from "../primitives/types"; import { typedFnType } from "../structures/types"; import { Bool, Byte, Char, Double, Int } from "../primitives/types"; import { deepEqual } from "../util/util"; import { eqDictType } from "./eq_dict"; export const getEq = numDict => numDict.eq; export const ModuleEq = {l:[ // type constructor: Type -> Type ...typedFnType(eqDictType, fnType => fnType(() => Type)(() => Type)), // (EqDict a) -> a -> a -> Bool ...typedFnType(getEq, fnType => makeGeneric(a => fnType (eqDictType(a)) (fnType (a) (fnType (a) (Bool) ) )), GenericType), ]}; // 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], [Unit , eqDict], [Type , eqDict], [SymbolT, eqDict], ]);