import { makeGeneric } from "../generics/generics"; import { 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_type"; 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) ) ))), ]}; // 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], ]);