@fpjs/overture
Version:
A Javascript prelude
28 lines (27 loc) • 825 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isSetoid = exports.ineq = exports.equals = exports.eq = void 0;
var _base = require("@fpjs/overture/base");
var _ord = require("@fpjs/overture/algebras/ord");
const isSetoid = x => (0, _ord.isOrd)(x) || "fantasy-land/equals" in x;
exports.isSetoid = isSetoid;
const equals = x => y => {
if ((0, _base.isPrimitive)(x)) {
return x === y;
}
const op = x["fantasy-land/equals"];
if (op === undefined) {
if ((0, _ord.isOrd)(x)) {
return (0, _ord.lte)(x)(y) && (0, _ord.lte)(y)(x);
} else {
throw TypeError(`'${(0, _base.type)(x)}' is not a Setoid.`);
}
}
return x === y || op.call(x, y);
};
exports.equals = equals;
const eq = exports.eq = equals;
const ineq = x => y => !eq(x)(y);
exports.ineq = ineq;